mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
Parse fixes (#9987)
* Added overriden version of extend in Parse.User * added type declaration of Parse.Promise.when with varargs * making Promise compatible with IPromise * fixed when: it is enough to have IPromise here * added Parse.Config class * fixed save/saveAll signatures * any object is allowed as function response * more precise signature for Parse.Object#find * request has a property object in beforeSave triggers * fixed types of trigger request & response objects * better fetch signatures * fixed typing for JobStatus * ErrorCode enum needs to be inlined in order to not create a dependency on the type definition * fixed return types of Parse.Promise#then * fixed typing of Parse.Promise.error * added static function Object.registerSubclass * fixed signature of Object#save * removed wrongly typed signatures; User inherits the correcrt ones from Object * added signature for Object#createAt and Object#updatedAt * javaScriptKey is optional according to https://github.com/ParsePlatform/Parse-SDK-JS/blob/v1.8.5/src/Parse.js * added class Session with methods typed according to https://parse.com/docs/js/api/classes/Parse.Session.html
This commit is contained in:
committed by
Mohamed Hegazy
parent
76a755c007
commit
71f47713ff
Vendored
+59
-30
@@ -67,29 +67,30 @@ declare namespace Parse {
|
||||
|
||||
interface IPromise<T> {
|
||||
|
||||
then<U>(resolvedCallback: (value: T) => IPromise<U>, rejectedCallback?: (reason: any) => IPromise<U>): IPromise<T>;
|
||||
then<U>(resolvedCallback: (value: T) => U, rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (value: T) => U, rejectedCallback?: (reason: any) => U): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => IPromise<U>, rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => U, rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => U, rejectedCallback?: (reason: any) => U): IPromise<U>;
|
||||
}
|
||||
|
||||
class Promise<T> {
|
||||
class Promise<T> implements IPromise<T> {
|
||||
|
||||
static as<U>(resolvedValue: U): Promise<U>;
|
||||
static error<U>(error: U): Promise<U>;
|
||||
static error<U, V>(error: U): Promise<V>;
|
||||
static is(possiblePromise: any): Boolean;
|
||||
static when(promises: Promise<any>[]): Promise<any>;
|
||||
static when(promises: IPromise<any>[]): Promise<any>;
|
||||
static when(...promises: IPromise<any>[]): Promise<any>;
|
||||
|
||||
always(callback: Function): Promise<T>;
|
||||
done(callback: Function): Promise<T>;
|
||||
fail(callback: Function): Promise<T>;
|
||||
reject(error: any): void;
|
||||
resolve(result: any): void;
|
||||
then<U>(resolvedCallback: (value: T) => Promise<U>,
|
||||
rejectedCallback?: (reason: any) => Promise<U>): IPromise<T>;
|
||||
then<U>(resolvedCallback: (value: T) => U,
|
||||
rejectedCallback?: (reason: any) => IPromise<U>): IPromise<T>;
|
||||
then<U>(resolvedCallback: (value: T) => U,
|
||||
rejectedCallback?: (reason: any) => U): IPromise<T>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => IPromise<U>,
|
||||
rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => U,
|
||||
rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => U,
|
||||
rejectedCallback?: (reason: any) => U): IPromise<U>;
|
||||
}
|
||||
|
||||
interface IBaseObject {
|
||||
@@ -306,7 +307,9 @@ declare namespace Parse {
|
||||
*/
|
||||
class Object extends BaseObject {
|
||||
|
||||
id: any;
|
||||
id: string;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
attributes: any;
|
||||
cid: string;
|
||||
changed: boolean;
|
||||
@@ -319,7 +322,9 @@ declare namespace Parse {
|
||||
static fetchAll<T>(list: Object[], options: SuccessFailureOptions): Promise<T>;
|
||||
static fetchAllIfNeeded<T>(list: Object[], options: SuccessFailureOptions): Promise<T>;
|
||||
static destroyAll<T>(list: Object[], options?: Object.DestroyAllOptions): Promise<T>;
|
||||
static saveAll<T>(list: Object[], options?: Object.SaveAllOptions): Promise<T>;
|
||||
static saveAll<T extends Object>(list: T[], options?: Object.SaveAllOptions): Promise<T[]>;
|
||||
|
||||
static registerSubclass<T extends Object>(className: string, clazz: new (options?: any) => T): void;
|
||||
|
||||
initialize(): void;
|
||||
add(attr: string, item: any): Object;
|
||||
@@ -333,7 +338,7 @@ declare namespace Parse {
|
||||
dirtyKeys(): string[];
|
||||
escape(attr: string): string;
|
||||
existed(): boolean;
|
||||
fetch<T>(options?: Object.FetchOptions): Promise<T>;
|
||||
fetch<T extends Object>(options?: Object.FetchOptions): Promise<T>;
|
||||
get(attr: string): any;
|
||||
getACL(): ACL;
|
||||
has(attr: string): boolean;
|
||||
@@ -345,7 +350,8 @@ declare namespace Parse {
|
||||
previousAttributes(): any;
|
||||
relation(attr: string): Relation;
|
||||
remove(attr: string, item: any): any;
|
||||
save<T>(options?: Object.SaveOptions, arg2?: any, arg3?: any): Promise<T>;
|
||||
save<T extends Object>(attrs?: { [key: string]: any }, options?: Object.SaveOptions): Promise<T>;
|
||||
save<T extends Object>(key: string, value: any, options?: Object.SaveOptions): Promise<T>;
|
||||
set(key: string, value: any, options?: Object.SetOptions): boolean;
|
||||
setACL(acl: ACL, options?: SuccessFailureOptions): boolean;
|
||||
unset(attr: string, options?: any): any;
|
||||
@@ -587,7 +593,7 @@ declare namespace Parse {
|
||||
endsWith(key: string, suffix: string): Query;
|
||||
equalTo(key: string, value: any): Query;
|
||||
exists(key: string): Query;
|
||||
find<T>(options?: Query.FindOptions): Promise<T>;
|
||||
find<T extends Object>(options?: Query.FindOptions): Promise<T[]>;
|
||||
first<T>(options?: Query.FirstOptions): Promise<T>;
|
||||
get(objectId: string, options?: Query.GetOptions): Promise<any>;
|
||||
greaterThan(key: string, value: any): Query;
|
||||
@@ -642,6 +648,21 @@ declare namespace Parse {
|
||||
setName(name: string, options?: SuccessFailureOptions): any;
|
||||
}
|
||||
|
||||
class Config extends Object {
|
||||
static get(options?: SuccessFailureOptions): Promise<Config>;
|
||||
static current(): Config;
|
||||
|
||||
get(attr: string): any;
|
||||
escape(attr: string): any;
|
||||
}
|
||||
|
||||
class Session extends Object {
|
||||
static current(): Promise<Session>;
|
||||
|
||||
getSessionToken(): string;
|
||||
isCurrentSessionRevocable(): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routers map faux-URLs to actions, and fire events when routes are
|
||||
* matched. Creating a new one sets its `routes` hash, if not set statically.
|
||||
@@ -698,11 +719,10 @@ declare namespace Parse {
|
||||
static allowCustomUserClass(isAllowed: boolean): void;
|
||||
static become<T>(sessionToken: string, options?: SuccessFailureOptions): Promise<T>;
|
||||
static requestPasswordReset<T>(email: string, options?: SuccessFailureOptions): Promise<T>;
|
||||
static extend(protoProps?: any, classProps?: any): any;
|
||||
|
||||
signUp<T>(attrs: any, options?: SuccessFailureOptions): Promise<T>;
|
||||
logIn<T>(options?: SuccessFailureOptions): Promise<T>;
|
||||
fetch<T>(options?: SuccessFailureOptions): Promise<T>;
|
||||
save<T>(arg1: any, arg2: any, arg3: any): Promise<T>;
|
||||
authenticated(): boolean;
|
||||
isCurrent(): boolean;
|
||||
|
||||
@@ -822,9 +842,9 @@ declare namespace Parse {
|
||||
}
|
||||
|
||||
interface JobStatus {
|
||||
error?: Function;
|
||||
message?: Function;
|
||||
success?: Function;
|
||||
error?: (response: any) => void;
|
||||
message?: (response: any) => void;
|
||||
success?: (response: any) => void;
|
||||
}
|
||||
|
||||
interface FunctionRequest {
|
||||
@@ -835,8 +855,8 @@ declare namespace Parse {
|
||||
}
|
||||
|
||||
interface FunctionResponse {
|
||||
success?: (response: HttpResponse) => void;
|
||||
error?: (response: HttpResponse) => void;
|
||||
success?: (response: any) => void;
|
||||
error?: (response: any) => void;
|
||||
}
|
||||
|
||||
interface Cookie {
|
||||
@@ -845,12 +865,18 @@ declare namespace Parse {
|
||||
value?: string;
|
||||
}
|
||||
|
||||
interface AfterSaveRequest extends FunctionRequest {}
|
||||
interface SaveRequest extends FunctionRequest {
|
||||
object: Object;
|
||||
}
|
||||
|
||||
interface AfterSaveRequest extends SaveRequest {}
|
||||
interface AfterDeleteRequest extends FunctionRequest {}
|
||||
interface BeforeDeleteRequest extends FunctionRequest {}
|
||||
interface BeforeDeleteResponse extends FunctionResponse {}
|
||||
interface BeforeSaveRequest extends FunctionRequest {}
|
||||
interface BeforeSaveResponse extends FunctionResponse {}
|
||||
interface BeforeSaveRequest extends SaveRequest {}
|
||||
interface BeforeSaveResponse extends FunctionResponse {
|
||||
success?: () => void;
|
||||
}
|
||||
|
||||
function afterDelete(arg1: any, func?: (request: AfterDeleteRequest) => void): void;
|
||||
function afterSave(arg1: any, func?: (request: AfterSaveRequest) => void): void;
|
||||
@@ -911,7 +937,10 @@ declare namespace Parse {
|
||||
|
||||
}
|
||||
|
||||
enum ErrorCode {
|
||||
/*
|
||||
* We need to inline the codes in order to make compilation work without this type definition as dependency.
|
||||
*/
|
||||
const enum ErrorCode {
|
||||
|
||||
OTHER_CAUSE = -1,
|
||||
INTERNAL_SERVER_ERROR = 1,
|
||||
@@ -1043,10 +1072,10 @@ declare namespace Parse {
|
||||
* Call this method first to set up your authentication tokens for Parse.
|
||||
* You can get your keys from the Data Browser on parse.com.
|
||||
* @param {String} applicationId Your Parse Application ID.
|
||||
* @param {String} javaScriptKey Your Parse JavaScript Key.
|
||||
* @param {String} javaScriptKey (optional) Your Parse JavaScript Key (Not needed for parse-server)
|
||||
* @param {String} masterKey (optional) Your Parse Master Key. (Node.js only!)
|
||||
*/
|
||||
function initialize(applicationId: string, javaScriptKey: string, masterKey?: string): void;
|
||||
function initialize(applicationId: string, javaScriptKey?: string, masterKey?: string): void;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user