From c6da4d659700c2206acc949b337e5bf7db4700ec Mon Sep 17 00:00:00 2001 From: Elad Zelingher Date: Wed, 7 Oct 2015 12:49:51 +0300 Subject: [PATCH 1/3] Updating autobahnjs declarations --- autobahn/autobahn.d.ts | 97 +++++++++++++++++++++++++++++++++++------- 1 file changed, 82 insertions(+), 15 deletions(-) diff --git a/autobahn/autobahn.d.ts b/autobahn/autobahn.d.ts index ceaf21230..223f45de7 100644 --- a/autobahn/autobahn.d.ts +++ b/autobahn/autobahn.d.ts @@ -4,6 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// declare module autobahn { @@ -49,24 +50,52 @@ declare module autobahn { procedure: string; } - interface IEvent { + class Invocation implements IInvocation { + constructor(caller?: number, progress?: boolean, procedure?: string); + + procedure: string; + } + + interface IEvent { publication: number; publisher?: number; topic: string; } - interface IResult { + class Event implements IEvent { + constructor(publication?: number, publisher?: string, topic?: string); + + publication: number; + topic: string; + } + + interface IResult { args: any[]; kwargs: any; } - interface IError { + class Result implements IResult { + constructor(args? : any[], kwargs? : any); + + args: any[]; + kwargs: any; + } + + interface IError { error: string; args: any[]; kwargs: any; - } + } - type SubscribeHandler = (args?: any[], kwargs?: any, details?: IEvent) => void; + class Error implements IError { + constructor(error? : string, args? : any[], kwargs? : any); + + error: string; + args: any[]; + kwargs: any; + } + + type SubscribeHandler = (args?: any[], kwargs?: any, details?: IEvent) => void; interface ISubscription { topic: string; @@ -78,7 +107,19 @@ declare module autobahn { unsubscribe(): When.Promise; } - type RegisterEndpoint = (args?: any[], kwargs?: any, details?: IInvocation) => void; + class Subscription implements ISubscription { + constructor(topic?, handler?: SubscribeHandler, options?:ISubscribeOptions, session?:Session, id?:number); + + handler: SubscribeHandler; + unsubscribe(): When.Promise; + topic: string; + options: ISubscribeOptions; + session: Session; + id: number; + active: boolean; + } + + type RegisterEndpoint = (args?: any[], kwargs?: any, details?: IInvocation) => void; interface IRegistration { procedure: string; @@ -90,11 +131,31 @@ declare module autobahn { unregister(): When.Promise; } - interface IPublication { - id: number; - } + class Registration implements IRegistration { + constructor(procedure? : string, endpoint? : RegisterEndpoint, options? : IRegisterOptions, session? : Session, id? : number); - interface ICallOptions { + endpoint : RegisterEndpoint; + + unregister(): When.Promise; + + procedure: string; + options: IRegisterOptions; + session: Session; + id: number; + active: boolean; + } + + interface IPublication { + id: number; + } + + class Publication implements IPublication { + constructor(id : number); + + id: number; + } + + interface ICallOptions { timeout?: number; receive_progress?: boolean; disclose_me?: boolean; @@ -131,7 +192,7 @@ declare module autobahn { type: string; } - type DeferFactory = () => any; + type DeferFactory = () => JQueryPromise; type OnChallengeHandler = (session: Session, method: string, extra: any) => When.Promise; @@ -170,7 +231,7 @@ declare module autobahn { } interface ITransportFactory { - //constructor(options: any); + // constructor(options: any); type: string; create(): ITransport; } @@ -179,7 +240,7 @@ declare module autobahn { register(name: string, factory: any): void; isRegistered(name: string): boolean; get(name: string): any; - list(): any[]; + list(): string[]; } interface ILog { @@ -190,9 +251,15 @@ declare module autobahn { assert(condition: boolean, message: string): void; } - var util: IUtil; + interface IAuthCra { + derive_key(secret: string, salt: string, iterations: number, keylen: number): string; + sign(key: string, challenge: string): string; + } + + var util: IUtil; var log: ILog; - var transports: ITransports; + var transports: ITransports; + var auth_cra: IAuthCra; } declare module "autobahn" { From e69bd05af7a41713519882d662695f4f18f8d239 Mon Sep 17 00:00:00 2001 From: Elad Zelingher Date: Wed, 7 Oct 2015 13:18:50 +0300 Subject: [PATCH 2/3] Fixing indentation --- autobahn/autobahn.d.ts | 284 +++++++++++++++++++++-------------------- 1 file changed, 143 insertions(+), 141 deletions(-) diff --git a/autobahn/autobahn.d.ts b/autobahn/autobahn.d.ts index 223f45de7..eefe55bf5 100644 --- a/autobahn/autobahn.d.ts +++ b/autobahn/autobahn.d.ts @@ -8,47 +8,47 @@ declare module autobahn { - export class Session { - id: number; - realm: string; - isOpen: boolean; - features: any; - caller_disclose_me: boolean; - publisher_disclose_me: boolean; - subscriptions: ISubscription[][]; - registrations: IRegistration[]; + export class Session { + id: number; + realm: string; + isOpen: boolean; + features: any; + caller_disclose_me: boolean; + publisher_disclose_me: boolean; + subscriptions: ISubscription[][]; + registrations: IRegistration[]; - constructor(transport: ITransport, defer: DeferFactory, challenge: OnChallengeHandler); + constructor(transport: ITransport, defer: DeferFactory, challenge: OnChallengeHandler); - join(realm: string, authmethods: string[], authid: string): void; + join(realm: string, authmethods: string[], authid: string): void; - leave(reason: string, message: string): void; + leave(reason: string, message: string): void; - call(procedure: string, args?: any[], kwargs?: any, options?: ICallOptions): When.Promise; + call(procedure: string, args?: any[], kwargs?: any, options?: ICallOptions): When.Promise; - publish(topic: string, args?: any[], kwargs?: any, options?: IPublishOptions): When.Promise; + publish(topic: string, args?: any[], kwargs?: any, options?: IPublishOptions): When.Promise; - subscribe(topic: string, handler: SubscribeHandler, options?: ISubscribeOptions): When.Promise; + subscribe(topic: string, handler: SubscribeHandler, options?: ISubscribeOptions): When.Promise; - register(procedure: string, endpoint: RegisterEndpoint, options?: IRegisterOptions): When.Promise; + register(procedure: string, endpoint: RegisterEndpoint, options?: IRegisterOptions): When.Promise; - unsubscribe(subscription: ISubscription): When.Promise; + unsubscribe(subscription: ISubscription): When.Promise; - unregister(registration: IRegistration): When.Promise; + unregister(registration: IRegistration): When.Promise; - prefix(prefix: string, uri: string): void; + prefix(prefix: string, uri: string): void; - resolve(curie: string): string; + resolve(curie: string): string; - onjoin: (roleFeatures: any) => void; - onleave: (reason: string, details: any) => void; - } + onjoin: (roleFeatures: any) => void; + onleave: (reason: string, details: any) => void; + } - interface IInvocation { - caller?: number; - progress?: boolean; - procedure: string; - } + interface IInvocation { + caller?: number; + progress?: boolean; + procedure: string; + } class Invocation implements IInvocation { constructor(caller?: number, progress?: boolean, procedure?: string); @@ -57,10 +57,10 @@ declare module autobahn { } interface IEvent { - publication: number; - publisher?: number; - topic: string; - } + publication: number; + publisher?: number; + topic: string; + } class Event implements IEvent { constructor(publication?: number, publisher?: string, topic?: string); @@ -70,25 +70,25 @@ declare module autobahn { } interface IResult { - args: any[]; - kwargs: any; - } + args: any[]; + kwargs: any; + } class Result implements IResult { - constructor(args? : any[], kwargs? : any); + constructor(args?: any[], kwargs?: any); args: any[]; kwargs: any; } interface IError { - error: string; - args: any[]; - kwargs: any; + error: string; + args: any[]; + kwargs: any; } class Error implements IError { - constructor(error? : string, args? : any[], kwargs? : any); + constructor(error?: string, args?: any[], kwargs?: any); error: string; args: any[]; @@ -97,21 +97,23 @@ declare module autobahn { type SubscribeHandler = (args?: any[], kwargs?: any, details?: IEvent) => void; - interface ISubscription { - topic: string; - handler: SubscribeHandler; - options: ISubscribeOptions; - session: Session; - id: number; - active: boolean; - unsubscribe(): When.Promise; - } + interface ISubscription { + topic: string; + handler: SubscribeHandler; + options: ISubscribeOptions; + session: Session; + id: number; + active: boolean; + unsubscribe(): When.Promise; + } class Subscription implements ISubscription { - constructor(topic?, handler?: SubscribeHandler, options?:ISubscribeOptions, session?:Session, id?:number); + constructor(topic?, handler?: SubscribeHandler, options?: ISubscribeOptions, session?: Session, id?: number); handler: SubscribeHandler; + unsubscribe(): When.Promise; + topic: string; options: ISubscribeOptions; session: Session; @@ -121,20 +123,20 @@ declare module autobahn { type RegisterEndpoint = (args?: any[], kwargs?: any, details?: IInvocation) => void; - interface IRegistration { - procedure: string; - endpoint: RegisterEndpoint; - options: IRegisterOptions; - session: Session; - id: number; - active: boolean; - unregister(): When.Promise; - } + interface IRegistration { + procedure: string; + endpoint: RegisterEndpoint; + options: IRegisterOptions; + session: Session; + id: number; + active: boolean; + unregister(): When.Promise; + } class Registration implements IRegistration { - constructor(procedure? : string, endpoint? : RegisterEndpoint, options? : IRegisterOptions, session? : Session, id? : number); + constructor(procedure?: string, endpoint?: RegisterEndpoint, options?: IRegisterOptions, session?: Session, id?: number); - endpoint : RegisterEndpoint; + endpoint: RegisterEndpoint; unregister(): When.Promise; @@ -146,110 +148,110 @@ declare module autobahn { } interface IPublication { - id: number; + id: number; } class Publication implements IPublication { - constructor(id : number); + constructor(id: number); id: number; } interface ICallOptions { - timeout?: number; - receive_progress?: boolean; - disclose_me?: boolean; - } + timeout?: number; + receive_progress?: boolean; + disclose_me?: boolean; + } - interface IPublishOptions { - exclude?: number[]; - eligible?: number[]; - disclose_me? : Boolean; - } + interface IPublishOptions { + exclude?: number[]; + eligible?: number[]; + disclose_me?: Boolean; + } - interface ISubscribeOptions { - match? : string; - } + interface ISubscribeOptions { + match?: string; + } - interface IRegisterOptions { - disclose_caller?: boolean; - } + interface IRegisterOptions { + disclose_caller?: boolean; + } - export class Connection { - constructor(options?: IConnectionOptions); + export class Connection { + constructor(options?: IConnectionOptions); - open(): void; + open(): void; - close(reason: string, message: string): void; + close(reason: string, message: string): void; - onopen: (session: Session, details: any) => void; - onclose: (reason: string, details: any) => boolean; - } + onopen: (session: Session, details: any) => void; + onclose: (reason: string, details: any) => boolean; + } - interface ITransportDefinition { - url?: string; - protocols?: string[]; - type: string; - } + interface ITransportDefinition { + url?: string; + protocols?: string[]; + type: string; + } - type DeferFactory = () => JQueryPromise; + type DeferFactory = () => JQueryPromise; - type OnChallengeHandler = (session: Session, method: string, extra: any) => When.Promise; + type OnChallengeHandler = (session: Session, method: string, extra: any) => When.Promise; - interface IConnectionOptions { - use_es6_promises?: boolean; - // use explicit deferred factory, e.g. jQuery.Deferred or Q.defer - use_deferred?: DeferFactory; - transports?: ITransportDefinition[]; - retry_if_unreachable?: boolean; - max_retries?: number; - initial_retry_delay?: number; - max_retry_delay?: number; - retry_delay_growth?: number; - retry_delay_jitter?: number; - url?: string; - protocols?: string[]; - onchallenge?: (session: Session, method: string, extra: any) => OnChallengeHandler; - realm?: string; - authmethods?: string[]; - authid?: string; - } + interface IConnectionOptions { + use_es6_promises?: boolean; + // use explicit deferred factory, e.g. jQuery.Deferred or Q.defer + use_deferred?: DeferFactory; + transports?: ITransportDefinition[]; + retry_if_unreachable?: boolean; + max_retries?: number; + initial_retry_delay?: number; + max_retry_delay?: number; + retry_delay_growth?: number; + retry_delay_jitter?: number; + url?: string; + protocols?: string[]; + onchallenge?: (session: Session, method: string, extra: any) => OnChallengeHandler; + realm?: string; + authmethods?: string[]; + authid?: string; + } - interface ICloseEventDetails { - wasClean: boolean; - reason: string; - code: number; - } + interface ICloseEventDetails { + wasClean: boolean; + reason: string; + code: number; + } - interface ITransport { - onopen: () => void; - onmessage: (message: any[]) => void; - onclose: (details: ICloseEventDetails) => void; + interface ITransport { + onopen: () => void; + onmessage: (message: any[]) => void; + onclose: (details: ICloseEventDetails) => void; - send(message: any[]): void; - close(errorCode: number, reason?: string): void; - } + send(message: any[]): void; + close(errorCode: number, reason?: string): void; + } - interface ITransportFactory { - // constructor(options: any); - type: string; - create(): ITransport; - } + interface ITransportFactory { + // constructor(options: any); + type: string; + create(): ITransport; + } - interface ITransports { - register(name: string, factory: any): void; - isRegistered(name: string): boolean; - get(name: string): any; - list(): string[]; - } + interface ITransports { + register(name: string, factory: any): void; + isRegistered(name: string): boolean; + get(name: string): any; + list(): string[]; + } - interface ILog { - debug(...args: any[]): void; - } + interface ILog { + debug(...args: any[]): void; + } - interface IUtil { - assert(condition: boolean, message: string): void; - } + interface IUtil { + assert(condition: boolean, message: string): void; + } interface IAuthCra { derive_key(secret: string, salt: string, iterations: number, keylen: number): string; @@ -257,11 +259,11 @@ declare module autobahn { } var util: IUtil; - var log: ILog; + var log: ILog; var transports: ITransports; var auth_cra: IAuthCra; } declare module "autobahn" { - export = autobahn; + export = autobahn; } From cf79a93a21077ed91bb622c8e1ea3019de81fb03 Mon Sep 17 00:00:00 2001 From: Elad Zelingher Date: Wed, 7 Oct 2015 13:33:31 +0300 Subject: [PATCH 3/3] Removed implicitAny --- autobahn/autobahn.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autobahn/autobahn.d.ts b/autobahn/autobahn.d.ts index eefe55bf5..6debcca7c 100644 --- a/autobahn/autobahn.d.ts +++ b/autobahn/autobahn.d.ts @@ -108,7 +108,7 @@ declare module autobahn { } class Subscription implements ISubscription { - constructor(topic?, handler?: SubscribeHandler, options?: ISubscribeOptions, session?: Session, id?: number); + constructor(topic? : string, handler?: SubscribeHandler, options?: ISubscribeOptions, session?: Session, id?: number); handler: SubscribeHandler;