mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-17 03:24:15 +08:00
Parse.Relation.add and Parse.Relation.remove can accept a Array and Parse.Object set and save methods can receive a object as parameter (#22774)
* Parse.Relation.add and Parse.Relation.remove can accept a Array of Parse.Object * Parse.Object set and save methods can receive a object as parameter * Parse.User signup method options fix
This commit is contained in:
committed by
Wesley Wigham
parent
78d7216f75
commit
4f78eeadb2
21
types/parse/index.d.ts
vendored
21
types/parse/index.d.ts
vendored
@@ -31,6 +31,11 @@ declare namespace Parse {
|
||||
interface SuccessFailureOptions extends SuccessOption, ErrorOption {
|
||||
}
|
||||
|
||||
interface SignUpOptions {
|
||||
useMasterKey?: boolean;
|
||||
installationId?: string;
|
||||
}
|
||||
|
||||
interface SessionTokenOption {
|
||||
sessionToken?: string;
|
||||
}
|
||||
@@ -98,11 +103,11 @@ declare namespace Parse {
|
||||
reject(error: any): void;
|
||||
resolve(result: any): void;
|
||||
then<U>(resolvedCallback: (...values: T[]) => IPromise<U>,
|
||||
rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => U,
|
||||
rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => U,
|
||||
rejectedCallback?: (reason: any) => U): IPromise<U>;
|
||||
rejectedCallback?: (reason: any) => U): IPromise<U>;
|
||||
}
|
||||
|
||||
interface Pointer {
|
||||
@@ -287,13 +292,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<T>): void;
|
||||
|
||||
// Returns a Parse.Query that is limited to objects in this relation.
|
||||
query(): Query<T>;
|
||||
|
||||
// Removes a Parse.Object or an array of Parse.Objects from this relation.
|
||||
remove(object: T): void;
|
||||
remove(object: T | Array<T>): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,7 +378,9 @@ declare namespace Parse {
|
||||
remove(attr: string, item: any): any;
|
||||
save(attrs?: { [key: string]: any } | null, options?: Object.SaveOptions): Promise<this>;
|
||||
save(key: string, value: any, options?: Object.SaveOptions): Promise<this>;
|
||||
save(attrs: object, options?: Object.SaveOptions): Promise<this>;
|
||||
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;
|
||||
@@ -739,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<User>;
|
||||
static signUp(username: string, password: string, attrs: any, options?: SignUpOptions): Promise<User>;
|
||||
static logIn(username: string, password: string, options?: SuccessFailureOptions): Promise<User>;
|
||||
static logOut(): Promise<User>;
|
||||
static allowCustomUserClass(isAllowed: boolean): void;
|
||||
@@ -747,7 +754,7 @@ declare namespace Parse {
|
||||
static requestPasswordReset(email: string, options?: SuccessFailureOptions): Promise<User>;
|
||||
static extend(protoProps?: any, classProps?: any): any;
|
||||
|
||||
signUp(attrs: any, options?: SuccessFailureOptions): Promise<this>;
|
||||
signUp(attrs: any, options?: SignUpOptions): Promise<this>;
|
||||
logIn(options?: SuccessFailureOptions): Promise<this>;
|
||||
authenticated(): boolean;
|
||||
isCurrent(): boolean;
|
||||
|
||||
@@ -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");
|
||||
@@ -235,7 +241,23 @@ 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() {
|
||||
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() {
|
||||
@@ -266,6 +288,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();
|
||||
|
||||
@@ -358,7 +381,7 @@ function test_cloud_functions() {
|
||||
});
|
||||
|
||||
Parse.Cloud.beforeDelete('MyCustomClass', (request: Parse.Cloud.BeforeDeleteRequest,
|
||||
response: Parse.Cloud.BeforeDeleteResponse) => {
|
||||
response: Parse.Cloud.BeforeDeleteResponse) => {
|
||||
// result
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user