diff --git a/autobahn/autobahn-tests.ts b/autobahn/autobahn-tests.ts index ee9c41b3e..5cdc4f95c 100644 --- a/autobahn/autobahn-tests.ts +++ b/autobahn/autobahn-tests.ts @@ -1,5 +1,7 @@ /// +import autobahn = require("autobahn"); + class MyClass { add2Count: number = 0; session: autobahn.Session; @@ -44,4 +46,4 @@ function test_client() { }; connection.open(); -} \ No newline at end of file +} diff --git a/autobahn/autobahn.d.ts b/autobahn/autobahn.d.ts index 7191e9c4f..ceaf21230 100644 --- a/autobahn/autobahn.d.ts +++ b/autobahn/autobahn.d.ts @@ -1,195 +1,200 @@ -// Type definitions for AutobahnJS v0.9.6 +// Type definitions for AutobahnJS v0.9.6 // Project: http://autobahn.ws/js/ -// Definitions by: Elad Zelingher +// Definitions by: Elad Zelingher , Andy Hawkins // Definitions: https://github.com/borisyankov/DefinitelyTyped /// + 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; + } - interface IEvent { - publication: number; - publisher?: number; - topic: string; - } + interface IEvent { + publication: number; + publisher?: number; + topic: string; + } - interface IResult { - args: any[]; - kwargs: any; - } + interface IResult { + args: any[]; + kwargs: any; + } - interface IError { - error: string; - args: any[]; - kwargs: any; - } + interface IError { + error: string; + args: any[]; + kwargs: any; + } - type SubscribeHandler = (args?: any[], kwargs?: any, details?: IEvent) => void; + 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; + } - type RegisterEndpoint = (args?: any[], kwargs?: any, details?: IInvocation) => void; + 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; + } - interface IPublication { - id: number; - } + interface IPublication { + id: number; + } - interface ICallOptions { - timeout?: number; - receive_progress?: boolean; - disclose_me?: boolean; - } + interface ICallOptions { + 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 = () => any; + type DeferFactory = () => any; - 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(): any[]; - } + interface ITransports { + register(name: string, factory: any): void; + isRegistered(name: string): boolean; + get(name: string): any; + list(): any[]; + } - 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; + } - var util: IUtil; - var log: ILog; - var transports: ITransports; -} \ No newline at end of file + var util: IUtil; + var log: ILog; + var transports: ITransports; +} + +declare module "autobahn" { + export = autobahn; +}