parse 8.0.1 → 8.0.2-alpha.2
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/README.md +4 -5
- package/dist/parse.js +1 -1
- package/dist/parse.min.js +1 -1
- package/dist/parse.weapp.js +1 -1
- package/dist/parse.weapp.min.js +1 -1
- package/lib/browser/CloudCode.js +222 -195
- package/lib/browser/CoreManager.js +1 -1
- package/lib/node/CloudCode.js +221 -195
- package/lib/node/CoreManager.js +1 -1
- package/lib/react-native/CloudCode.js +12 -0
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/weapp/CloudCode.js +222 -195
- package/lib/weapp/CoreManager.js +1 -1
- package/package.json +15 -12
- package/types/CloudCode.d.ts +391 -175
- package/types/node.d.ts +46 -0
- package/types/tests.ts +238 -151
package/lib/browser/CloudCode.js
CHANGED
|
@@ -1,66 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ReadPreferenceOption = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* @typedef Parse.Cloud.FunctionRequest
|
|
10
|
+
* @property {string} installationId If set, the installationId triggering the request.
|
|
11
|
+
* @property {boolean} master If true, means the master key was used.
|
|
12
|
+
* @property {Parse.User} user If set, the user that made the request.
|
|
13
|
+
* @property {object} params The params passed to the cloud function.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @typedef Parse.Cloud.TriggerRequest
|
|
17
|
+
* @property {string} installationId If set, the installationId triggering the request.
|
|
18
|
+
* @property {boolean} master If true, means the master key was used.
|
|
19
|
+
* @property {Parse.User} user If set, the user that made the request.
|
|
20
|
+
* @property {Parse.Object} object The object triggering the hook.
|
|
21
|
+
* @property {string} ip The IP address of the client making the request.
|
|
22
|
+
* @property {object} headers The original HTTP headers for the request.
|
|
23
|
+
* @property {string} triggerName The name of the trigger (`beforeSave`, `afterSave`, ...)
|
|
24
|
+
* @property {object} log The current logger inside Parse Server.
|
|
25
|
+
* @property {Parse.Object} original If set, the object, as currently stored.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @typedef Parse.Cloud.FileTriggerRequest
|
|
29
|
+
* @property {string} installationId If set, the installationId triggering the request.
|
|
30
|
+
* @property {boolean} master If true, means the master key was used.
|
|
31
|
+
* @property {Parse.User} user If set, the user that made the request.
|
|
32
|
+
* @property {Parse.File} file The file triggering the hook.
|
|
33
|
+
* @property {string} ip The IP address of the client making the request.
|
|
34
|
+
* @property {object} headers The original HTTP headers for the request.
|
|
35
|
+
* @property {string} triggerName The name of the trigger (`beforeSaveFile`, `afterSaveFile`, ...)
|
|
36
|
+
* @property {object} log The current logger inside Parse Server.
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* @typedef Parse.Cloud.ConnectTriggerRequest
|
|
40
|
+
* @property {string} installationId If set, the installationId triggering the request.
|
|
41
|
+
* @property {boolean} useMasterKey If true, means the master key was used.
|
|
42
|
+
* @property {Parse.User} user If set, the user that made the request.
|
|
43
|
+
* @property {number} clients The number of clients connected.
|
|
44
|
+
* @property {number} subscriptions The number of subscriptions connected.
|
|
45
|
+
* @property {string} sessionToken If set, the session of the user that made the request.
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* @typedef Parse.Cloud.JobRequest
|
|
49
|
+
* @property {object} params The params passed to the background job.
|
|
50
|
+
* @property {Function} message If message is called with a string argument, will update the current message to be stored in the job status.
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* @typedef Parse.Cloud.HTTPOptions
|
|
54
|
+
* @property {string | object} body The body of the request.
|
|
55
|
+
* @property {boolean} followRedirects Whether to follow redirects caused by HTTP 3xx responses. Defaults to false.
|
|
56
|
+
* @property {object} headers The headers for the request.
|
|
57
|
+
* @property {string} method The method of the request. GET, POST, PUT, DELETE, HEAD, and OPTIONS are supported.
|
|
58
|
+
* @property {string | object} params The query portion of the url.
|
|
59
|
+
* @property {string} url The url to send the request to.
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* @typedef Parse.Cloud.HTTPResponse
|
|
63
|
+
* @property {Buffer} buffer The raw byte representation of the response body.
|
|
64
|
+
* @property {object} cookies The cookies sent by the server.
|
|
65
|
+
* @property {object} data The parsed response body as a JavaScript object.
|
|
66
|
+
* @property {object} headers The headers sent by the server.
|
|
67
|
+
* @property {number} status The status code.
|
|
68
|
+
* @property {string} text The raw text representation of the response body.
|
|
69
|
+
*/
|
|
70
|
+
let ReadPreferenceOption = exports.ReadPreferenceOption = /*#__PURE__*/function (ReadPreferenceOption) {
|
|
71
|
+
ReadPreferenceOption["Primary"] = "PRIMARY";
|
|
72
|
+
ReadPreferenceOption["PrimaryPreferred"] = "PRIMARY_PREFERRED";
|
|
73
|
+
ReadPreferenceOption["Secondary"] = "SECONDARY";
|
|
74
|
+
ReadPreferenceOption["SecondaryPreferred"] = "SECONDARY_PREFERRED";
|
|
75
|
+
ReadPreferenceOption["Nearest"] = "NEAREST";
|
|
76
|
+
return ReadPreferenceOption;
|
|
77
|
+
}({});
|
|
1
78
|
/**
|
|
2
79
|
* Defines a Cloud Function.
|
|
3
80
|
*
|
|
4
81
|
* **Available in Cloud Code only.**
|
|
5
82
|
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
8
|
-
* @param
|
|
9
|
-
* @param {Function} data The Cloud Function to register. This function should take one parameter {@link Parse.Cloud.FunctionRequest}
|
|
83
|
+
* @param name The name of the Cloud Function
|
|
84
|
+
* @param handler The Cloud Function to register. This function should take one parameter {@link FunctionRequest}
|
|
85
|
+
* @param validator An optional function to validate the request
|
|
10
86
|
*/
|
|
11
|
-
|
|
12
87
|
/**
|
|
13
|
-
*
|
|
88
|
+
* Defines a Background Job.
|
|
89
|
+
*
|
|
90
|
+
* **Available in Cloud Code only.**
|
|
91
|
+
*
|
|
92
|
+
* @param name The name of the Background Job
|
|
93
|
+
* @param handler The Background Job to register. This function should take one parameter {@link JobRequest}
|
|
94
|
+
*/
|
|
95
|
+
/**
|
|
96
|
+
* Registers a before save function.
|
|
14
97
|
*
|
|
15
98
|
* **Available in Cloud Code only.**
|
|
16
99
|
*
|
|
17
|
-
* If you want to use
|
|
100
|
+
* If you want to use beforeSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}),
|
|
101
|
+
* you should pass the class itself and not the String for arg1.
|
|
102
|
+
*
|
|
18
103
|
* ```
|
|
19
|
-
* Parse.Cloud.
|
|
104
|
+
* Parse.Cloud.beforeSave('MyCustomClass', (request) => {
|
|
20
105
|
* // code here
|
|
21
106
|
* })
|
|
22
107
|
*
|
|
23
|
-
* Parse.Cloud.
|
|
108
|
+
* Parse.Cloud.beforeSave(Parse.User, (request) => {
|
|
24
109
|
* // code here
|
|
25
110
|
* })
|
|
26
|
-
|
|
111
|
+
* ```
|
|
27
112
|
*
|
|
28
|
-
* @function
|
|
29
|
-
* @
|
|
30
|
-
* @param
|
|
31
|
-
* @param {Function} func The function to run after a delete. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}.
|
|
113
|
+
* @param className The Parse.Object subclass to register the before save function for.
|
|
114
|
+
* @param handler The function to run before a save.
|
|
115
|
+
* @param validator An optional function to validate the request
|
|
32
116
|
*/
|
|
33
|
-
|
|
34
117
|
/**
|
|
35
|
-
*
|
|
36
118
|
* Registers an after save function.
|
|
37
119
|
*
|
|
38
120
|
* **Available in Cloud Code only.**
|
|
39
121
|
*
|
|
40
|
-
* If you want to use afterSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}),
|
|
122
|
+
* If you want to use afterSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}),
|
|
123
|
+
* you should pass the class itself and not the String for arg1.
|
|
41
124
|
*
|
|
42
125
|
* ```
|
|
43
|
-
* Parse.Cloud.afterSave('MyCustomClass',
|
|
126
|
+
* Parse.Cloud.afterSave('MyCustomClass', (request) => {
|
|
44
127
|
* // code here
|
|
45
128
|
* })
|
|
46
129
|
*
|
|
47
|
-
* Parse.Cloud.afterSave(Parse.User,
|
|
130
|
+
* Parse.Cloud.afterSave(Parse.User, (request) => {
|
|
48
131
|
* // code here
|
|
49
132
|
* })
|
|
50
133
|
* ```
|
|
51
134
|
*
|
|
52
|
-
* @function
|
|
53
|
-
* @
|
|
54
|
-
* @param
|
|
55
|
-
* @param {Function} func The function to run after a save. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}.
|
|
135
|
+
* @param className The Parse.Object subclass to register the after save function for.
|
|
136
|
+
* @param handler The function to run after a save.
|
|
137
|
+
* @param validator An optional function to validate the request
|
|
56
138
|
*/
|
|
57
|
-
|
|
58
139
|
/**
|
|
59
|
-
* Registers
|
|
140
|
+
* Registers a before delete function.
|
|
60
141
|
*
|
|
61
142
|
* **Available in Cloud Code only.**
|
|
62
143
|
*
|
|
63
|
-
* If you want to use beforeDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}),
|
|
144
|
+
* If you want to use beforeDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}),
|
|
145
|
+
* you should pass the class itself and not the String for arg1.
|
|
146
|
+
*
|
|
64
147
|
* ```
|
|
65
148
|
* Parse.Cloud.beforeDelete('MyCustomClass', (request) => {
|
|
66
149
|
* // code here
|
|
@@ -69,115 +152,133 @@
|
|
|
69
152
|
* Parse.Cloud.beforeDelete(Parse.User, (request) => {
|
|
70
153
|
* // code here
|
|
71
154
|
* })
|
|
72
|
-
|
|
155
|
+
* ```
|
|
73
156
|
*
|
|
74
|
-
* @function
|
|
75
|
-
* @
|
|
76
|
-
* @param
|
|
77
|
-
* @param {Function} func The function to run before a delete. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}.
|
|
157
|
+
* @param className The Parse.Object subclass to register the before delete function for.
|
|
158
|
+
* @param handler The function to run before a delete.
|
|
159
|
+
* @param validator An optional function to validate the request
|
|
78
160
|
*/
|
|
79
|
-
|
|
80
161
|
/**
|
|
81
|
-
*
|
|
82
|
-
* Registers an before save function.
|
|
162
|
+
* Registers an after delete function.
|
|
83
163
|
*
|
|
84
164
|
* **Available in Cloud Code only.**
|
|
85
165
|
*
|
|
86
|
-
* If you want to use
|
|
166
|
+
* If you want to use afterDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}),
|
|
167
|
+
* you should pass the class itself and not the String for arg1.
|
|
87
168
|
*
|
|
88
169
|
* ```
|
|
89
|
-
* Parse.Cloud.
|
|
170
|
+
* Parse.Cloud.afterDelete('MyCustomClass', (request) => {
|
|
90
171
|
* // code here
|
|
91
172
|
* })
|
|
92
173
|
*
|
|
93
|
-
* Parse.Cloud.
|
|
174
|
+
* Parse.Cloud.afterDelete(Parse.User, (request) => {
|
|
94
175
|
* // code here
|
|
95
176
|
* })
|
|
96
177
|
* ```
|
|
97
178
|
*
|
|
98
|
-
* @function
|
|
99
|
-
* @
|
|
100
|
-
* @param
|
|
101
|
-
* @param {Function} func The function to run before a save. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}.
|
|
179
|
+
* @param className The Parse.Object subclass to register the after delete function for.
|
|
180
|
+
* @param handler The function to run after a delete.
|
|
181
|
+
* @param validator An optional function to validate the request
|
|
102
182
|
*/
|
|
103
|
-
|
|
104
183
|
/**
|
|
184
|
+
* Registers a before find function.
|
|
105
185
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
186
|
+
* **Available in Cloud Code only.**
|
|
187
|
+
*
|
|
188
|
+
* @param className The Parse.Object subclass to register the before find function for.
|
|
189
|
+
* @param handler The function to run before a find.
|
|
190
|
+
* @param validator An optional function to validate the request
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* Registers an after find function.
|
|
109
194
|
*
|
|
110
195
|
* **Available in Cloud Code only.**
|
|
111
196
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
*
|
|
197
|
+
* @param className The Parse.Object subclass to register the after find function for.
|
|
198
|
+
* @param handler The function to run after a find.
|
|
199
|
+
* @param validator An optional function to validate the request
|
|
200
|
+
*/
|
|
201
|
+
/**
|
|
202
|
+
* Registers a before login function.
|
|
118
203
|
*
|
|
119
|
-
*
|
|
204
|
+
* **Available in Cloud Code only.**
|
|
120
205
|
*
|
|
121
|
-
*
|
|
206
|
+
* @param handler The function to run before a login.
|
|
207
|
+
* @param validator An optional function to validate the request
|
|
208
|
+
*/
|
|
209
|
+
/**
|
|
210
|
+
* Registers an after login function.
|
|
122
211
|
*
|
|
123
|
-
*
|
|
124
|
-
* Parse.Cloud.beforeSaveFile(({ file, user }) => {
|
|
125
|
-
* return user.get('avatar');
|
|
126
|
-
* });
|
|
212
|
+
* **Available in Cloud Code only.**
|
|
127
213
|
*
|
|
128
|
-
*
|
|
214
|
+
* @param handler The function to run after a login.
|
|
215
|
+
*/
|
|
216
|
+
/**
|
|
217
|
+
* Registers an after logout function.
|
|
218
|
+
*
|
|
219
|
+
* **Available in Cloud Code only.**
|
|
220
|
+
*
|
|
221
|
+
* @param handler The function to run after a logout.
|
|
222
|
+
*/
|
|
223
|
+
/**
|
|
224
|
+
* Registers a before password reset request function.
|
|
225
|
+
*
|
|
226
|
+
* **Available in Cloud Code only.**
|
|
129
227
|
*
|
|
130
|
-
*
|
|
228
|
+
* @param handler The function to run before a password reset request.
|
|
229
|
+
* @param validator An optional function to validate the request
|
|
230
|
+
*/
|
|
231
|
+
/**
|
|
232
|
+
* Registers a before save file function.
|
|
233
|
+
*
|
|
234
|
+
* **Available in Cloud Code only.**
|
|
235
|
+
*
|
|
236
|
+
* A new Parse.File can be returned to override the file that gets saved.
|
|
131
237
|
*
|
|
132
238
|
* ```
|
|
133
239
|
* Parse.Cloud.beforeSaveFile(({ file, user }) => {
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* const newFile = new Parse.File(file.name(), <some other file data>, 'text/plain', metadata, tags);
|
|
137
|
-
* return newFile;
|
|
240
|
+
* file.addMetadata('foo', 'bar');
|
|
241
|
+
* file.addTag('createdBy', user.id);
|
|
138
242
|
* });
|
|
139
|
-
*
|
|
140
243
|
* ```
|
|
141
244
|
*
|
|
142
|
-
* @function
|
|
143
|
-
* @name Parse.Cloud.beforeSaveFile
|
|
144
|
-
* @param {Function} func The function to run before a file saves. This function should take one parameter, a {@link Parse.Cloud.FileTriggerRequest}.
|
|
245
|
+
* @param handler The function to run before a file saves.
|
|
145
246
|
*/
|
|
146
|
-
|
|
147
247
|
/**
|
|
148
|
-
*
|
|
149
248
|
* Registers an after save file function.
|
|
150
249
|
*
|
|
151
250
|
* **Available in Cloud Code only.**
|
|
152
251
|
*
|
|
153
|
-
* Example: creating a new object that references this file in a separate collection
|
|
154
252
|
* ```
|
|
155
253
|
* Parse.Cloud.afterSaveFile(async ({ file, user }) => {
|
|
156
254
|
* const fileObject = new Parse.Object('FileObject');
|
|
157
|
-
* fileObject.set('metadata', file.metadata());
|
|
158
|
-
* fileObject.set('tags', file.tags());
|
|
159
255
|
* fileObject.set('name', file.name());
|
|
160
256
|
* fileObject.set('createdBy', user);
|
|
161
257
|
* await fileObject.save({ sessionToken: user.getSessionToken() });
|
|
162
258
|
* });
|
|
259
|
+
* ```
|
|
163
260
|
*
|
|
164
|
-
* @
|
|
165
|
-
* @name Parse.Cloud.afterSaveFile
|
|
166
|
-
* @param {Function} func The function to run after a file saves. This function should take one parameter, a {@link Parse.Cloud.FileTriggerRequest}.
|
|
261
|
+
* @param handler The function to run after a file saves.
|
|
167
262
|
*/
|
|
168
|
-
|
|
169
263
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
264
|
+
* Registers a before delete file function.
|
|
265
|
+
*
|
|
266
|
+
* **Available in Cloud Code only.**
|
|
267
|
+
*
|
|
268
|
+
* @param handler The function to run before a file is deleted.
|
|
173
269
|
*/
|
|
174
270
|
/**
|
|
271
|
+
* Registers an after delete file function.
|
|
175
272
|
*
|
|
176
|
-
*
|
|
273
|
+
* **Available in Cloud Code only.**
|
|
274
|
+
*
|
|
275
|
+
* @param handler The function to run after a file is deleted.
|
|
276
|
+
*/
|
|
277
|
+
/**
|
|
278
|
+
* Registers a before connect function for LiveQuery.
|
|
177
279
|
*
|
|
178
280
|
* **Available in Cloud Code only.**
|
|
179
281
|
*
|
|
180
|
-
* Example: restrict LiveQueries to logged in users.
|
|
181
282
|
* ```
|
|
182
283
|
* Parse.Cloud.beforeConnect((request) => {
|
|
183
284
|
* if (!request.user) {
|
|
@@ -185,142 +286,68 @@
|
|
|
185
286
|
* }
|
|
186
287
|
* });
|
|
187
288
|
* ```
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
* @function 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}.
|
|
289
|
+
*
|
|
290
|
+
* @param handler The function to run before a LiveQuery connection is made.
|
|
291
|
+
* @param validator An optional function to validate the request
|
|
195
292
|
*/
|
|
196
293
|
/**
|
|
197
|
-
*
|
|
198
|
-
* Registers a before subscribe function.
|
|
294
|
+
* Registers a before subscribe function for LiveQuery.
|
|
199
295
|
*
|
|
200
296
|
* **Available in Cloud Code only.**
|
|
201
|
-
*
|
|
297
|
+
*
|
|
202
298
|
* ```
|
|
203
|
-
*
|
|
299
|
+
* Parse.Cloud.beforeSubscribe('MyObject', (request) => {
|
|
204
300
|
* if (!request.user.get('Admin')) {
|
|
205
|
-
*
|
|
301
|
+
* throw new Parse.Error(101, 'You are not authorized to subscribe to MyObject.');
|
|
206
302
|
* }
|
|
207
|
-
* let query = request.query;
|
|
208
|
-
* query.select("name","year")
|
|
303
|
+
* let query = request.query;
|
|
304
|
+
* query.select("name", "year");
|
|
209
305
|
* });
|
|
210
306
|
* ```
|
|
307
|
+
*
|
|
308
|
+
* @param className The Parse.Object subclass to register the before subscribe function for.
|
|
309
|
+
* @param handler The function to run before a subscription.
|
|
310
|
+
* @param validator An optional function to validate the request
|
|
311
|
+
*/
|
|
312
|
+
/**
|
|
313
|
+
* Registers an after live query event function.
|
|
314
|
+
*
|
|
315
|
+
* **Available in Cloud Code only.**
|
|
316
|
+
*
|
|
317
|
+
* @param className The Parse.Object subclass to register the after live query event function for.
|
|
318
|
+
* @param handler The function to run after a live query event.
|
|
319
|
+
* @param validator An optional function to validate the request
|
|
320
|
+
*/
|
|
321
|
+
/**
|
|
322
|
+
* Sends an email.
|
|
323
|
+
*
|
|
324
|
+
* **Available in Cloud Code only.**
|
|
325
|
+
*
|
|
326
|
+
* @param data The email data.
|
|
327
|
+
* @param data.from The sender email address.
|
|
328
|
+
* @param data.to The recipient email address.
|
|
329
|
+
* @param data.subject The email subject.
|
|
330
|
+
* @param data.text The plain text content.
|
|
331
|
+
* @param data.html The HTML content.
|
|
211
332
|
*/
|
|
212
|
-
|
|
213
333
|
/**
|
|
214
334
|
* Makes an HTTP Request.
|
|
215
335
|
*
|
|
216
336
|
* **Available in Cloud Code only.**
|
|
217
337
|
*
|
|
218
|
-
* By default, Parse.Cloud.httpRequest does not follow redirects caused by HTTP 3xx response codes.
|
|
338
|
+
* By default, Parse.Cloud.httpRequest does not follow redirects caused by HTTP 3xx response codes.
|
|
339
|
+
* You can use the followRedirects option in the {@link HTTPOptions} object to change this behavior.
|
|
219
340
|
*
|
|
220
|
-
* Sample request:
|
|
221
341
|
* ```
|
|
222
342
|
* Parse.Cloud.httpRequest({
|
|
223
343
|
* url: 'http://www.example.com/'
|
|
224
344
|
* }).then(function(httpResponse) {
|
|
225
|
-
* // success
|
|
226
345
|
* console.log(httpResponse.text);
|
|
227
|
-
* },function(httpResponse) {
|
|
228
|
-
* // error
|
|
346
|
+
* }, function(httpResponse) {
|
|
229
347
|
* console.error('Request failed with response code ' + httpResponse.status);
|
|
230
348
|
* });
|
|
231
349
|
* ```
|
|
232
350
|
*
|
|
233
|
-
* @
|
|
234
|
-
* @
|
|
235
|
-
|
|
236
|
-
* @returns {Promise<Parse.Cloud.HTTPResponse>} A promise that will be resolved with a {@link Parse.Cloud.HTTPResponse} object when the request completes.
|
|
237
|
-
*/
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Defines a Background Job.
|
|
241
|
-
*
|
|
242
|
-
* **Available in Cloud Code only.**
|
|
243
|
-
*
|
|
244
|
-
* @function job
|
|
245
|
-
* @name Parse.Cloud.job
|
|
246
|
-
* @param {string} name The name of the Background Job
|
|
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}
|
|
248
|
-
*/
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* @typedef Parse.Cloud.TriggerRequest
|
|
252
|
-
* @property {string} installationId If set, the installationId triggering the request.
|
|
253
|
-
* @property {boolean} master If true, means the master key was used.
|
|
254
|
-
* @property {Parse.User} user If set, the user that made the request.
|
|
255
|
-
* @property {Parse.Object} object The object triggering the hook.
|
|
256
|
-
* @property {string} ip The IP address of the client making the request.
|
|
257
|
-
* @property {object} headers The original HTTP headers for the request.
|
|
258
|
-
* @property {string} triggerName The name of the trigger (`beforeSave`, `afterSave`, ...)
|
|
259
|
-
* @property {object} log The current logger inside Parse Server.
|
|
260
|
-
* @property {Parse.Object} original If set, the object, as currently stored.
|
|
261
|
-
*/
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* @typedef Parse.Cloud.FileTriggerRequest
|
|
265
|
-
* @property {string} installationId If set, the installationId triggering the request.
|
|
266
|
-
* @property {boolean} master If true, means the master key was used.
|
|
267
|
-
* @property {Parse.User} user If set, the user that made the request.
|
|
268
|
-
* @property {Parse.File} file The file triggering the hook.
|
|
269
|
-
* @property {string} ip The IP address of the client making the request.
|
|
270
|
-
* @property {object} headers The original HTTP headers for the request.
|
|
271
|
-
* @property {string} triggerName The name of the trigger (`beforeSaveFile`, `afterSaveFile`, ...)
|
|
272
|
-
* @property {object} log The current logger inside Parse Server.
|
|
273
|
-
*/
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* @typedef Parse.Cloud.ConnectTriggerRequest
|
|
277
|
-
* @property {string} installationId If set, the installationId triggering the request.
|
|
278
|
-
* @property {boolean} useMasterKey If true, means the master key was used.
|
|
279
|
-
* @property {Parse.User} user If set, the user that made the request.
|
|
280
|
-
* @property {number} clients The number of clients connected.
|
|
281
|
-
* @property {number} subscriptions The number of subscriptions connected.
|
|
282
|
-
* @property {string} sessionToken If set, the session of the user that made the request.
|
|
283
|
-
*/
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* @typedef Parse.Cloud.FunctionRequest
|
|
287
|
-
* @property {string} installationId If set, the installationId triggering the request.
|
|
288
|
-
* @property {boolean} master If true, means the master key was used.
|
|
289
|
-
* @property {Parse.User} user If set, the user that made the request.
|
|
290
|
-
* @property {object} params The params passed to the cloud function.
|
|
291
|
-
*/
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* @typedef Parse.Cloud.JobRequest
|
|
295
|
-
* @property {object} params The params passed to the background job.
|
|
296
|
-
*/
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* @typedef Parse.Cloud.JobStatus
|
|
300
|
-
* @property {Function} error If error is called, will end the job unsuccessfully with an optional completion message to be stored in the job status.
|
|
301
|
-
* @property {Function} message If message is called with a string argument, will update the current message to be stored in the job status.
|
|
302
|
-
* @property {Function} success If success is called, will end the job successfullly with the optional completion message to be stored in the job status.
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* @typedef Parse.Cloud.HTTPOptions
|
|
307
|
-
* @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.
|
|
308
|
-
* @property {Function} error The function that is called when the request fails. It will be passed a Parse.Cloud.HTTPResponse object.
|
|
309
|
-
* @property {boolean} followRedirects Whether to follow redirects caused by HTTP 3xx responses. Defaults to false.
|
|
310
|
-
* @property {object} headers The headers for the request.
|
|
311
|
-
* @property {string} method The method of the request. GET, POST, PUT, DELETE, HEAD, and OPTIONS are supported. Will default to GET if not specified.
|
|
312
|
-
* @property {string | object} params The query portion of the url. You can pass a JSON object of key value pairs like params: {q : 'Sean Plott'} or a raw string like params:q=Sean Plott.
|
|
313
|
-
* @property {Function} success The function that is called when the request successfully completes. It will be passed a Parse.Cloud.HTTPResponse object.
|
|
314
|
-
* @property {string} url The url to send the request to.
|
|
315
|
-
*/
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* @typedef Parse.Cloud.HTTPResponse
|
|
319
|
-
* @property {Buffer} buffer The raw byte representation of the response body. Use this to receive binary data. See Buffer for more details.
|
|
320
|
-
* @property {object} cookies The cookies sent by the server. The keys in this object are the names of the cookies. The values are Parse.Cloud.Cookie objects.
|
|
321
|
-
* @property {object} data The parsed response body as a JavaScript object. This is only available when the response Content-Type is application/x-www-form-urlencoded or application/json.
|
|
322
|
-
* @property {object} headers The headers sent by the server. The keys in this object are the names of the headers. We do not support multiple response headers with the same name. In the common case of Set-Cookie headers, please use the cookies field instead.
|
|
323
|
-
* @property {number} status The status code.
|
|
324
|
-
* @property {string} text The raw text representation of the response body.
|
|
325
|
-
*/
|
|
326
|
-
"use strict";
|
|
351
|
+
* @param options The HTTPOptions object that makes the request.
|
|
352
|
+
* @returns A promise that will be resolved with a {@link HTTPResponse} object when the request completes.
|
|
353
|
+
*/
|