From c48ecfcb12a0519094e285ce99dd564ba711809d Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Sun, 2 Aug 2015 23:45:43 +0100 Subject: [PATCH] Postal.js v1.0.6 --- postal/postal-0.8.9.d.ts | 71 ++++++++++++++++++++++++++++ postal/postal.d.ts | 99 +++++++++++++++++++++++++++------------- 2 files changed, 138 insertions(+), 32 deletions(-) create mode 100644 postal/postal-0.8.9.d.ts diff --git a/postal/postal-0.8.9.d.ts b/postal/postal-0.8.9.d.ts new file mode 100644 index 0000000000..0ef40c5d51 --- /dev/null +++ b/postal/postal-0.8.9.d.ts @@ -0,0 +1,71 @@ +// Type definitions for Postal v0.8.9 +// Project: https://github.com/postaljs/postal.js +// Definitions by: Lokesh Peta +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface IConfiguration{ + SYSTEM_CHANNEL: string; + DEFAULT_CHANNEL: string; + resolver: any; +} + +interface ISubscriptionDefinition{ + unsubscribe(): void; + subscribe(callback: (data: any, envelope: IEnvelope)=> void): void; + defer():ISubscriptionDefinition; + disposeAfter(maxCalls: number): ISubscriptionDefinition; + distinctUntilChanged(): ISubscriptionDefinition; + once(): ISubscriptionDefinition; + withConstraint(predicate: Function): ISubscriptionDefinition; + withConstraints(predicates: Array): ISubscriptionDefinition; + + withContext(context: any): ISubscriptionDefinition; + withDebounce(milliseconds: number, immediate: boolean ): ISubscriptionDefinition; + withDelay(milliseconds: number): ISubscriptionDefinition; + withThrottle(milliseconds: number): ISubscriptionDefinition; +} + +interface IEnvelope{ + topic: string; + data?: any; + + /*Uses DEFAULT_CHANNEL if no channel is provided*/ + channel?: string; + + timeStamp?: string; +} + + +interface IChannelDefinition { + subscribe(topic: string): ISubscriptionDefinition; + subscribe(topic: string, callback: (data: any, envelope: IEnvelope)=> void): ISubscriptionDefinition; + + publish(topic: string, data?: any): void; + publish(envelope: IEnvelope): void; + + channel: string; +} + +interface IPostalUtils{ + getSubscribersFor(channel: string, tpc: any): any; + reset(): void; +} + +interface IPostal { + channel(name?:string): IChannelDefinition; + + linkChannels(sources: IEnvelope | IEnvelope[], destinations: IEnvelope | IEnvelope[]): ISubscriptionDefinition[]; + + utils: IPostalUtils; + + configuration: IConfiguration; +} + +declare var postal: IPostal; + +declare module "postal" { + var postal: IPostal; + export = postal; +} \ No newline at end of file diff --git a/postal/postal.d.ts b/postal/postal.d.ts index 0ef40c5d51..e1bad48cce 100644 --- a/postal/postal.d.ts +++ b/postal/postal.d.ts @@ -1,33 +1,48 @@ -// Type definitions for Postal v0.8.9 +// Type definitions for Postal v1.0.6 // Project: https://github.com/postaljs/postal.js -// Definitions by: Lokesh Peta +// Definitions by: Lokesh Peta , Paul Jolly // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// - -interface IConfiguration{ +interface IConfiguration { SYSTEM_CHANNEL: string; DEFAULT_CHANNEL: string; - resolver: any; + resolver: IResolver; } -interface ISubscriptionDefinition{ - unsubscribe(): void; - subscribe(callback: (data: any, envelope: IEnvelope)=> void): void; - defer():ISubscriptionDefinition; +interface IResolver { + compare(binding: string, topic: string, headerOptions: {}): boolean; + reset(): void; + purge(options?: {topic?: string, binding?: string, compact?: boolean}): void; +} + +interface ICallback { + (data: any, envelope: IEnvelope): void +} + +interface ISubscriptionDefinition { + channel: string; + topic: string; + callback: ICallback; + + // after and before lack documentation + + constraint(predicateFn: (data: any, envelope: IEnvelope) => boolean): ISubscriptionDefinition; + constraints(predicateFns: ((data: any, envelope: IEnvelope) => boolean)[]): ISubscriptionDefinition; + context(theContext: any): ISubscriptionDefinition; + debounce(interval: number): ISubscriptionDefinition; + defer(): ISubscriptionDefinition; + delay(waitTime: number): ISubscriptionDefinition; disposeAfter(maxCalls: number): ISubscriptionDefinition; + distinct(): ISubscriptionDefinition; distinctUntilChanged(): ISubscriptionDefinition; + logError(): ISubscriptionDefinition; once(): ISubscriptionDefinition; - withConstraint(predicate: Function): ISubscriptionDefinition; - withConstraints(predicates: Array): ISubscriptionDefinition; - - withContext(context: any): ISubscriptionDefinition; - withDebounce(milliseconds: number, immediate: boolean ): ISubscriptionDefinition; - withDelay(milliseconds: number): ISubscriptionDefinition; - withThrottle(milliseconds: number): ISubscriptionDefinition; + throttle(interval: number): ISubscriptionDefinition; + subscribe(callback: ICallback): ISubscriptionDefinition; + unsubscribe(): void; } -interface IEnvelope{ +interface IEnvelope { topic: string; data?: any; @@ -39,26 +54,45 @@ interface IEnvelope{ interface IChannelDefinition { - subscribe(topic: string): ISubscriptionDefinition; - subscribe(topic: string, callback: (data: any, envelope: IEnvelope)=> void): ISubscriptionDefinition; + subscribe(topic: string, callback: ICallback): ISubscriptionDefinition; publish(topic: string, data?: any): void; - publish(envelope: IEnvelope): void; channel: string; } -interface IPostalUtils{ - getSubscribersFor(channel: string, tpc: any): any; - reset(): void; +interface ISourceArg { + topic: string; + channel?: string; +} + +interface IDestinationArg { + topic: string | ((topic: string) => string); + channel?: string; } interface IPostal { - channel(name?:string): IChannelDefinition; - - linkChannels(sources: IEnvelope | IEnvelope[], destinations: IEnvelope | IEnvelope[]): ISubscriptionDefinition[]; - - utils: IPostalUtils; + subscriptions: {}; + wiretaps: ICallback[]; + + addWireTap(callback: ICallback): () => void; + + channel(name?: string): IChannelDefinition; + + getSubscribersFor(): ISubscriptionDefinition[]; + getSubscribersFor(options: {channel?: string, topic?: string, context?: any}): ISubscriptionDefinition[]; + getSubscribersFor(predicateFn: (sub: ISubscriptionDefinition) => boolean): ISubscriptionDefinition[]; + + linkChannels(source: ISourceArg | ISourceArg[], destination: IDestinationArg | IDestinationArg[]): void; + + publish(envelope: IEnvelope): void; + + reset(): void; + + subscribe(options: {channel?: string, topic: string, callback: ICallback}): ISubscriptionDefinition; + unsubscribe(sub: ISubscriptionDefinition): void; + unsubscribeFor(): void; + unsubscribeFor(options: {channel?: string, topic?: string, context?: any}): void; configuration: IConfiguration; } @@ -66,6 +100,7 @@ interface IPostal { declare var postal: IPostal; declare module "postal" { - var postal: IPostal; - export = postal; -} \ No newline at end of file + var postal: IPostal; + export = postal; +} +