diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 50030bddd2..f47d3b9c72 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for parse 2.2.1 +// Type definitions for parse 2.2.9 // Project: https://parseplatform.org/ // Definitions by: Ullisen Media Group // David Poetzsch-Heffter @@ -13,6 +13,7 @@ // Julien Quere // Yago Tomé // Thibault MOCELLIN +// Raschid JF Rafaelly // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -31,6 +32,11 @@ declare namespace Parse { batchSize?: number; } + interface CascadeSaveOption { + /** If `false`, nested objects will not be saved (default is `true`). */ + cascadeSave?: boolean; + } + interface SuccessOption { success?: Function; } @@ -346,6 +352,7 @@ declare namespace Parse { remove(attr: string, item: any): this | false; removeAll(attr: string, items: any): this | false; revert(): void; + revert(...keys: string[]): void; save(attrs?: { [key: string]: any } | null, options?: Object.SaveOptions): Promise; save(key: string, value: any, options?: Object.SaveOptions): Promise; save(attrs: object, options?: Object.SaveOptions): Promise; @@ -368,7 +375,7 @@ declare namespace Parse { interface FetchOptions extends SuccessFailureOptions, ScopeOptions { } - interface SaveOptions extends SuccessFailureOptions, SilentOption, ScopeOptions, WaitOption { } + interface SaveOptions extends CascadeSaveOption, SuccessFailureOptions, SilentOption, ScopeOptions, WaitOption { } interface SaveAllOptions extends BatchSizeOption, ScopeOptions { } @@ -830,11 +837,31 @@ subscription.on('close', () => {}); function beforeFind(arg1: any, func?: (request: BeforeFindRequest) => Promise | Query): void; function afterFind(arg1: any, func?: (request: AfterFindRequest) => Promise | any): void; function define(name: string, func?: (request: FunctionRequest) => Promise | any): void; + /** + * Gets data for the current set of cloud jobs. + * @returns A promise that will be resolved with the result of the function. + */ + function getJobsData(): Promise; + /** + * Gets job status by Id + * @param jobStatusId The Id of Job Status. + * @returns Status of Job. + */ + function getJobStatus(jobStatusId: string): Promise; function httpRequest(options: HTTPOptions): Promise; function job(name: string, func?: (request: JobRequest) => Promise | void): HttpResponse; function run(name: string, data?: any, options?: RunOptions): Promise; + /** + * Starts a given cloud job, which will process asynchronously. + * @param jobName The function name. + * @param data The parameters to send to the cloud function. + * @returns A promise that will be resolved with the jobStatusId of the job. + */ + function startJob(jobName: string, data: any): Promise; function useMasterKey(): void; + + interface RunOptions extends SuccessFailureOptions, ScopeOptions { } /** diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 1edd64d684..fc3def614c 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -22,6 +22,13 @@ function test_object() { const game = new Game(); + game.save(null, { + useMasterKey: true, + sessionToken: 'sometoken', + cascadeSave: false, + }) + .then(result => result); + if (!game.isNew()) { console.error("Game should be new"); } @@ -286,6 +293,8 @@ function test_user_acl_roles() { game.save({ score: '10' }, { useMasterKey: true }).then(function (game) { // Update game then revert it to the last saved state. game.set("score", '20'); + game.revert('score'); + game.revert('score', 'ACL'); game.revert(); }, function (error) { // The save failed @@ -396,7 +405,7 @@ function test_cloud_functions() { const CUSTOM_ERROR_IMMUTABLE_FIELD = 1002 Parse.Cloud.beforeSave('MyCustomClass', async (request: Parse.Cloud.BeforeSaveRequest) => { - + if (request.object.isNew()) { if (!request.object.has('immutable')) throw new Error('Field immutable is required') } else { @@ -452,6 +461,12 @@ function test_cloud_functions() { Parse.Cloud.job('AJob', (request: Parse.Cloud.JobRequest) => { request.message('Message to associate with this job run'); }); + + Parse.Cloud.startJob('AJob', {}).then(v => v); + + Parse.Cloud.getJobStatus('AJob').then(v => v); + + Parse.Cloud.getJobsData().then(v => v); } class PlaceObject extends Parse.Object { }