@@ -14,6 +14,8 @@ import decode from './decode';
14
14
import encode from './encode' ;
15
15
import ParseError from './ParseError' ;
16
16
import ParseQuery from './ParseQuery' ;
17
+ import ParseObject from './ParseObject' ;
18
+ import type { RequestOptions } from './RESTController' ;
17
19
18
20
/**
19
21
* Contains functions for calling and declaring
@@ -40,8 +42,8 @@ import ParseQuery from './ParseQuery';
40
42
export function run (
41
43
name : string ,
42
44
data : mixed ,
43
- options : { [ key : string ] : mixed }
44
- ) : Promise {
45
+ options : RequestOptions
46
+ ) : Promise < mixed > {
45
47
options = options || { } ;
46
48
47
49
if ( typeof name !== 'string' || name . length === 0 ) {
@@ -66,7 +68,7 @@ export function run(
66
68
* @return {Promise } A promise that will be resolved with the result
67
69
* of the function.
68
70
*/
69
- export function getJobsData ( ) : Promise {
71
+ export function getJobsData ( ) : Promise < Object > {
70
72
const requestOptions = {
71
73
useMasterKey : true
72
74
} ;
@@ -79,13 +81,13 @@ export function getJobsData(): Promise {
79
81
* @name Parse.Cloud.startJob
80
82
* @param {String } name The function name.
81
83
* @param {Object } data The parameters to send to the cloud function.
82
- * @return {Promise } A promise that will be resolved with the result
83
- * of the function .
84
+ * @return {Promise } A promise that will be resolved with the jobStatusId
85
+ * of the job .
84
86
*/
85
87
export function startJob (
86
88
name : string ,
87
89
data : mixed ,
88
- ) : Promise {
90
+ ) : Promise < string > {
89
91
90
92
if ( typeof name !== 'string' || name . length === 0 ) {
91
93
throw new TypeError ( 'Cloud job name must be a string.' ) ;
@@ -103,13 +105,13 @@ export function startJob(
103
105
* @param {String } jobStatusId The Id of Job Status.
104
106
* @return {Parse.Object } Status of Job.
105
107
*/
106
- export function getJobStatus ( jobStatusId : string ) : Promise {
108
+ export function getJobStatus ( jobStatusId : string ) : Promise < ParseObject > {
107
109
const query = new ParseQuery ( '_JobStatus' ) ;
108
110
return query . get ( jobStatusId , { useMasterKey : true } ) ;
109
111
}
110
112
111
113
const DefaultController = {
112
- run ( name , data , options ) {
114
+ run ( name , data , options : RequestOptions ) {
113
115
const RESTController = CoreManager . getRESTController ( ) ;
114
116
115
117
const payload = encode ( data , true ) ;
@@ -138,7 +140,7 @@ const DefaultController = {
138
140
} ) ;
139
141
} ,
140
142
141
- getJobsData ( options ) {
143
+ getJobsData ( options : RequestOptions ) {
142
144
const RESTController = CoreManager . getRESTController ( ) ;
143
145
144
146
return RESTController . request (
@@ -149,7 +151,7 @@ const DefaultController = {
149
151
) ;
150
152
} ,
151
153
152
- startJob ( name , data , options ) {
154
+ startJob ( name , data , options : RequestOptions ) {
153
155
const RESTController = CoreManager . getRESTController ( ) ;
154
156
155
157
const payload = encode ( data , true ) ;
0 commit comments