|
62 | 62 | * |
63 | 63 | * If you want to use beforeDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1. |
64 | 64 | * ``` |
65 | | - * Parse.Cloud.beforeDelete('MyCustomClass', (request, response) => { |
| 65 | + * Parse.Cloud.beforeDelete('MyCustomClass', (request) => { |
66 | 66 | * // code here |
67 | 67 | * }) |
68 | 68 | * |
69 | | - * Parse.Cloud.beforeDelete(Parse.User, (request, response) => { |
| 69 | + * Parse.Cloud.beforeDelete(Parse.User, (request) => { |
70 | 70 | * // code here |
71 | 71 | * }) |
72 | 72 | *``` |
73 | 73 | * |
74 | 74 | * @method beforeDelete |
75 | 75 | * @name Parse.Cloud.beforeDelete |
76 | 76 | * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the before delete function for. This can instead be a String that is the className of the subclass. |
77 | | - * @param {Function} func The function to run before a delete. This function should take two parameters a {@link Parse.Cloud.TriggerRequest} and a {@link Parse.Cloud.BeforeDeleteResponse}. |
| 77 | + * @param {Function} func The function to run after a save. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}. |
78 | 78 | */ |
79 | 79 |
|
80 | 80 | /** |
|
86 | 86 | * If you want to use beforeSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1. |
87 | 87 | * |
88 | 88 | * ``` |
89 | | - * Parse.Cloud.beforeSave('MyCustomClass', (request, response) => { |
| 89 | + * Parse.Cloud.beforeSave('MyCustomClass', (request) => { |
90 | 90 | * // code here |
91 | 91 | * }) |
92 | 92 | * |
93 | | - * Parse.Cloud.beforeSave(Parse.User, (request, response) => { |
| 93 | + * Parse.Cloud.beforeSave(Parse.User, (request) => { |
94 | 94 | * // code here |
95 | 95 | * }) |
96 | 96 | * ``` |
97 | 97 | * |
98 | 98 | * @method beforeSave |
99 | 99 | * @name Parse.Cloud.beforeSave |
100 | 100 | * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass. |
101 | | - * @param {Function} func The function to run before a save. This function should take two parameters a {@link Parse.Cloud.TriggerRequest} and a {@link Parse.Cloud.BeforeSaveResponse}. |
| 101 | + * @param {Function} func The function to run after a save. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}. |
102 | 102 | */ |
103 | 103 |
|
104 | 104 | /** |
|
166 | 166 | * @param {Function} func The function to run after a file saves. This function should take one parameter, a {@link Parse.Cloud.FileTriggerRequest}. |
167 | 167 | */ |
168 | 168 |
|
| 169 | +/** |
| 170 | + * @method beforeConnect |
| 171 | + * @name Parse.Cloud.beforeConnect |
| 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 | + */ |
| 174 | +/** |
| 175 | + * |
| 176 | + * Registers a before connect function. |
| 177 | + * |
| 178 | + * **Available in Cloud Code only.** |
| 179 | + * |
| 180 | + * Example: restrict LiveQueries to logged in users. |
| 181 | + * ``` |
| 182 | + * Parse.Cloud.beforeConnect((request) => { |
| 183 | + * if (!request.user) { |
| 184 | + * throw "Please login before you attempt to connect." |
| 185 | + * } |
| 186 | + * }); |
| 187 | + * ``` |
| 188 | +*/ |
| 189 | + |
| 190 | +/** |
| 191 | + * @method beforeSubscribe |
| 192 | + * @name Parse.Cloud.beforeSubscribe |
| 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. |
| 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}. |
| 195 | + */ |
| 196 | +/** |
| 197 | + * |
| 198 | + * Registers a before subscribe function. |
| 199 | + * |
| 200 | + * **Available in Cloud Code only.** |
| 201 | + * Example: restrict subscriptions to MyObject to Admin accounts only. |
| 202 | + * ``` |
| 203 | + * Parse.Cloud.beforeSubscribe('MyObject', (request) => { |
| 204 | + * if (!request.user.get('Admin')) { |
| 205 | + * throw new Parse.Error(101, 'You are not authorized to subscribe to MyObject.'); |
| 206 | + * } |
| 207 | + * let query = request.query; // the Parse.Query |
| 208 | + * query.select("name","year") |
| 209 | + * }); |
| 210 | + * ``` |
| 211 | +*/ |
| 212 | + |
| 213 | + |
169 | 214 | /** |
170 | 215 | * Makes an HTTP Request. |
171 | 216 | * |
|
229 | 274 | * @property {Object} log The current logger inside Parse Server. |
230 | 275 | */ |
231 | 276 |
|
| 277 | +/** |
| 278 | + * @typedef Parse.Cloud.ConnectTriggerRequest |
| 279 | + * @property {String} installationId If set, the installationId triggering the request. |
| 280 | + * @property {Boolean} useMasterKey If true, means the master key was used. |
| 281 | + * @property {Parse.User} user If set, the user that made the request. |
| 282 | + * @property {Integer} clients The number of clients connected. |
| 283 | + * @property {Integer} subscriptions The number of subscriptions connected. |
| 284 | + * @property {String} sessionToken If set, the session of the user that made the request. |
| 285 | + */ |
| 286 | + |
232 | 287 | /** |
233 | 288 | * @typedef Parse.Cloud.FunctionRequest |
234 | 289 | * @property {String} installationId If set, the installationId triggering the request. |
|
249 | 304 | * @property {function} success If success is called, will end the job successfullly with the optional completion message to be stored in the job status. |
250 | 305 | */ |
251 | 306 |
|
252 | | -/** |
253 | | - * @typedef Parse.Cloud.BeforeSaveResponse |
254 | | - * @property {function} success If called, will allow the save to happen. If a Parse.Object is passed in, then the passed in object will be saved instead. |
255 | | - * @property {function} error If called, will reject the save. An optional error message may be passed in. |
256 | | - */ |
257 | | - |
258 | | -/** |
259 | | - * @typedef Parse.Cloud.BeforeDeleteResponse |
260 | | - * @property {function} success If called, will allow the delete to happen. |
261 | | - * @property {function} error If called, will reject the save. An optional error message may be passed in. |
262 | | - */ |
263 | | - |
264 | | -/** |
265 | | - * @typedef Parse.Cloud.FunctionResponse |
266 | | - * @property {function} success If success is called, will return a successful response with the optional argument to the caller. |
267 | | - * @property {function} error If error is called, will return an error response with an optionally passed message. |
268 | | - */ |
269 | | - |
270 | 307 | /** |
271 | 308 | * @typedef Parse.Cloud.HTTPOptions |
272 | 309 | * @property {String|Object} body The body of the request. If it is a JSON object, then the Content-Type set in the headers must be application/x-www-form-urlencoded or application/json. You can also set this to a {@link Buffer} object to send raw bytes. If you use a Buffer, you should also set the Content-Type header explicitly to describe what these bytes represent. |
|
0 commit comments