From e3a835a4dc33c942eb5b01c52af8fc2d394435ed Mon Sep 17 00:00:00 2001 From: Flavio Torres Date: Tue, 26 Sep 2017 23:52:20 -0300 Subject: [PATCH 1/5] Parse.Relation.add and Parse.Relation.remove can accept a Array of Parse.Object --- types/parse/index.d.ts | 4 ++-- types/parse/parse-tests.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 82194e65a2..ee79e94955 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -280,13 +280,13 @@ declare namespace Parse { constructor(parent?: S, key?: string); //Adds a Parse.Object or an array of Parse.Objects to the relation. - add(object: T): void; + add(object: T | Array): void; // Returns a Parse.Query that is limited to objects in this relation. query(): Query; // Removes a Parse.Object or an array of Parse.Objects from this relation. - remove(object: T): void; + remove(object: T | Array): void; } /** diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 76440e46d3..eba5adc91b 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -227,7 +227,15 @@ function test_analytics() { } function test_relation() { + var game1 = new Game(); + var game2 = new Game(); + new Parse.User().relation("games").query().find().then((g: Game[]) => { }); + new Parse.User().relation("games").add(game1) + new Parse.User().relation("games").add([game1, game2]) + + new Parse.User().relation("games").remove(game1) + new Parse.User().relation("games").remove([game1, game2]) } function test_user_acl_roles() { From 26d39cd9cf9cd16765f560cbe02b873ba5ba41a1 Mon Sep 17 00:00:00 2001 From: Flavio Torres Date: Tue, 9 Jan 2018 09:04:19 -0200 Subject: [PATCH 2/5] Parse.Object set and save methods can receive a object as parameter --- types/parse/index.d.ts | 8 +++++--- types/parse/parse-tests.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 8afefce1d5..0042e1d9e6 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -98,11 +98,11 @@ declare namespace Parse { reject(error: any): void; resolve(result: any): void; then(resolvedCallback: (...values: T[]) => IPromise, - rejectedCallback?: (reason: any) => IPromise): IPromise; + rejectedCallback?: (reason: any) => IPromise): IPromise; then(resolvedCallback: (...values: T[]) => U, - rejectedCallback?: (reason: any) => IPromise): IPromise; + rejectedCallback?: (reason: any) => IPromise): IPromise; then(resolvedCallback: (...values: T[]) => U, - rejectedCallback?: (reason: any) => U): IPromise; + rejectedCallback?: (reason: any) => U): IPromise; } interface Pointer { @@ -373,7 +373,9 @@ declare namespace Parse { remove(attr: string, item: any): any; 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; set(key: string, value: any, options?: Object.SetOptions): boolean; + set(attrs: object, options?: Object.SetOptions): boolean; setACL(acl: ACL, options?: SuccessFailureOptions): boolean; toPointer(): Pointer; unset(attr: string, options?: any): any; diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index dbfa82fa3f..2c122a295c 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -57,6 +57,12 @@ function test_object() { gameScore.set("cheatMode", false); + // Setting attrs using object + gameScore.set({ + level: '10', + difficult: 15 + }); + const score = gameScore.get("score"); const playerName = gameScore.get("playerName"); const cheatMode = gameScore.get("cheatMode"); @@ -274,6 +280,7 @@ function test_user_acl_roles() { game.setACL(new Parse.ACL(Parse.User.current())); game.save().then((game: Game) => { }); game.save(null, { useMasterKey: true }); + game.save({ score: '10' }, { useMasterKey: true }); const groupACL = new Parse.ACL(); @@ -366,7 +373,7 @@ function test_cloud_functions() { }); Parse.Cloud.beforeDelete('MyCustomClass', (request: Parse.Cloud.BeforeDeleteRequest, - response: Parse.Cloud.BeforeDeleteResponse) => { + response: Parse.Cloud.BeforeDeleteResponse) => { // result }); From 8656d6391434e77b76a5af0d8105922ca1029650 Mon Sep 17 00:00:00 2001 From: Flavio Torres Date: Tue, 9 Jan 2018 09:31:21 -0200 Subject: [PATCH 3/5] Parse.User signup method options fix --- types/parse/index.d.ts | 9 +++++++-- types/parse/parse-tests.ts | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index 0042e1d9e6..1973c8938b 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -31,6 +31,11 @@ declare namespace Parse { interface SuccessFailureOptions extends SuccessOption, ErrorOption { } + interface SignUpOptions { + useMasterKey?: boolean; + installationId?: string; + } + interface SessionTokenOption { sessionToken?: string; } @@ -741,7 +746,7 @@ declare namespace Parse { class User extends Object { static current(): User | undefined; - static signUp(username: string, password: string, attrs: any, options?: SuccessFailureOptions): Promise; + static signUp(username: string, password: string, attrs: any, options?: SignUpOptions): Promise; static logIn(username: string, password: string, options?: SuccessFailureOptions): Promise; static logOut(): Promise; static allowCustomUserClass(isAllowed: boolean): void; @@ -749,7 +754,7 @@ declare namespace Parse { static requestPasswordReset(email: string, options?: SuccessFailureOptions): Promise; static extend(protoProps?: any, classProps?: any): any; - signUp(attrs: any, options?: SuccessFailureOptions): Promise; + signUp(attrs: any, options?: SignUpOptions): Promise; logIn(options?: SuccessFailureOptions): Promise; authenticated(): boolean; isCurrent(): boolean; diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 2c122a295c..87194ba02c 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -252,6 +252,14 @@ function test_relation() { new Parse.User().relation("games").remove([game1, game2]) } +function test_user() { + const user = new Parse.User(); + user.set("username", "my name"); + user.set("password", "my pass"); + user.set("email", "email@example.com"); + user.signUp(null, { useMasterKey: true }); +} + function test_user_acl_roles() { const user = new Parse.User(); From 8564c357bb3fdb9b6bd5e17a5991f323e188e8f2 Mon Sep 17 00:00:00 2001 From: Flavio Torres Date: Thu, 15 Feb 2018 14:18:23 -0200 Subject: [PATCH 4/5] Added Beforefind readPreference options --- types/parse/index.d.ts | 22 +++++++++++++++------- types/parse/parse-tests.ts | 8 ++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/types/parse/index.d.ts b/types/parse/index.d.ts index d186211983..95331fe0d7 100644 --- a/types/parse/index.d.ts +++ b/types/parse/index.d.ts @@ -6,7 +6,7 @@ // Flavio Negrão // Wes Grimes // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 /// /// @@ -907,22 +907,30 @@ declare namespace Parse { object: Object; } - interface BeforeFindTriggerRequest extends TriggerRequest { - query?: Query - count?: boolean - } interface AfterSaveRequest extends TriggerRequest { } interface AfterDeleteRequest extends TriggerRequest { } interface BeforeDeleteRequest extends TriggerRequest { } interface BeforeDeleteResponse extends FunctionResponse { } interface BeforeSaveRequest extends TriggerRequest { } - interface BeforeFindRequest extends BeforeFindTriggerRequest { } interface BeforeSaveResponse extends FunctionResponse { success: () => void; } + + // Read preference describes how MongoDB driver route read operations to the members of a replica set. + enum ReadPreferenceOption { + Primary = 'PRIMARY', + PrimaryPreferred = 'PRIMARY_PREFERRED', + Secondary = 'SECONDARY', + SecondaryPreferred = 'SECONDARY_PREFERRED', + Nearest = 'NEAREST' + } + interface BeforeFindRequest extends TriggerRequest { - query: Query; + query: Query + count: boolean + isGet: boolean + readPreference?: ReadPreferenceOption } function afterDelete(arg1: any, func?: (request: AfterDeleteRequest) => void): void; diff --git a/types/parse/parse-tests.ts b/types/parse/parse-tests.ts index 06ec062880..b8d0d0dd0e 100644 --- a/types/parse/parse-tests.ts +++ b/types/parse/parse-tests.ts @@ -390,6 +390,14 @@ function test_cloud_functions() { let user = request.user; // the user let isMaster = request.master; // if the query is run with masterKey let isCount = request.count; // if the query is a count operation (available on parse-server 2.4.0 or up) + let isGet = request.isGet; // if the query is a get operation + + // All possible read preferences + request.readPreference = Parse.Cloud.ReadPreferenceOption.Primary + request.readPreference = Parse.Cloud.ReadPreferenceOption.PrimaryPreferred + request.readPreference = Parse.Cloud.ReadPreferenceOption.Secondary + request.readPreference = Parse.Cloud.ReadPreferenceOption.SecondaryPreferred + request.readPreference = Parse.Cloud.ReadPreferenceOption.Nearest }); } From 7af3a74feca151d9c91de5c7321dec46e4537123 Mon Sep 17 00:00:00 2001 From: Flavio Torres Date: Thu, 15 Feb 2018 16:04:08 -0200 Subject: [PATCH 5/5] updated requirements to TypeScript Version: 2.4 --- types/parse-mockdb/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/parse-mockdb/index.d.ts b/types/parse-mockdb/index.d.ts index bff2e81935..94a1f63bb1 100644 --- a/types/parse-mockdb/index.d.ts +++ b/types/parse-mockdb/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/HustleInc/parse-mockdb // Definitions by: David Poetzsch-Heffter // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 ///