This repository has been archived by the owner on May 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
/
index.d.ts
151 lines (116 loc) · 3.72 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Type definitions for webstomp-client v1.0.x
// Project: https://github.com/JSteunou/webstomp-client
// Definitions by: Jimi Charalampidis <https://github.com/JimiC>
// Rodolfo Aguirre <https://github.com/roddolf>
export function client(url: string, options?: Options): Client;
export function over(socketType: any, options?: Options): Client;
export class Client {
connected: boolean;
isBinary: boolean;
partialData: string;
subscriptions: SubscriptionsMap;
ws: any;
connect(headers: ConnectionHeaders, connectCallback: (frame?: Frame) => any, errorCallback?: (error: CloseEvent | Frame) => any): void;
connect(login: string, passcode: string, connectCallback: (frame?: Frame) => any, errorCallback?: (error: CloseEvent | Frame) => any, host?: string): void;
disconnect(disconnectCallback?: () => any, headers?: DisconnectHeaders): void;
send(destination: string, body?: string, headers?: ExtendedHeaders): void;
subscribe(destination: string, callback?: (message: Message) => any, headers?: SubscribeHeaders): Subscription;
unsubscribe(id: string, header?: UnsubscribeHeaders): void;
begin(transaction: string): void;
commit(transaction: string): void;
abort(transaction: string): void;
ack(messageID: string, subscription: Subscription, headers?: AckHeaders): void;
nack(messageID: string, subscription: Subscription, headers?: NackHeaders): void;
debug(...args: any[]): void;
onreceipt?(frame: Frame): void;
}
export class Frame {
command: string;
body: string;
headers: Headers;
constructor(command: string, headers?: Headers, body?: string);
toString(): string;
static unmarshallSingle(data: string): Frame;
static unmarshall(datas: string): { frames: Frame[], partial?: string };
static marshall(command: string, headers?: Headers, body?: string): string;
}
export const VERSIONS: {
V1_0: string,
V1_1: string,
V1_2: string,
// Versions of STOMP specifications supported
supportedVersions: () => string,
supportedProtocols: () => string[]
}
export interface Heartbeat {
outgoing: number,
incoming: number
}
export interface Subscription {
id: string;
unsubscribe: () => void;
}
export interface SubscriptionsMap {
[id: string]: (message: Message) => any;
}
export interface Message extends Frame {
headers: ExtendedHeaders;
ack(headers?: AckHeaders): any;
nack(headers?: NackHeaders): any;
}
export interface Options extends ClientOptions {
protocols?: string[];
}
export interface ClientOptions {
binary?: boolean;
heartbeat?: Heartbeat | boolean;
debug?: boolean;
}
export interface Headers {
[key: string]: string | undefined;
}
export interface ConnectionHeaders extends Headers {
login?: string;
passcode?: string;
host?: string;
}
export interface DisconnectHeaders extends Headers {
'receipt'?: string;
}
export interface StandardHeaders extends DisconnectHeaders {
'content-length'?: string;
'content-type'?: string;
}
export interface ExtendedHeaders extends StandardHeaders {
'amqp-message-id'?: string,
'app-id'?: string,
'content-encoding'?: string,
'correlation-id'?: string,
custom?: string,
destination?: string,
'message-id'?: string,
persistent?: string,
redelivered?: string,
'reply-to'?: string,
subscription?: string,
timestamp?: string,
type?: string,
}
export interface UnsubscribeHeaders extends StandardHeaders {
id?: string,
}
export interface SubscribeHeaders extends UnsubscribeHeaders {
ack?: string
}
export interface AckHeaders extends UnsubscribeHeaders {
transaction?: string
}
export interface NackHeaders extends AckHeaders {
}
declare const webstomp: {
Frame: Frame,
VERSIONS: typeof VERSIONS,
client: typeof client,
over: typeof over,
}
export default webstomp