forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 1
/
thrift.d.ts
281 lines (255 loc) · 12 KB
/
thrift.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
// Type definitions for thrift 0.9.2
// Project: https://www.npmjs.com/package/thrift
// Definitions by: Zachary Collins <https://github.com/corps>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
declare module "thrift" {
export module Thrift {
/**
* Thrift IDL type string to Id mapping.
* @property {number} STOP - End of a set of fields.
* @property {number} VOID - No value (only legal for return types).
* @property {number} BOOL - True/False integer.
* @property {number} BYTE - Signed 8 bit integer.
* @property {number} I08 - Signed 8 bit integer.
* @property {number} DOUBLE - 64 bit IEEE 854 floating point.
* @property {number} I16 - Signed 16 bit integer.
* @property {number} I32 - Signed 32 bit integer.
* @property {number} I64 - Signed 64 bit integer.
* @property {number} STRING - Array of bytes representing a string of characters.
* @property {number} UTF7 - Array of bytes representing a string of UTF7 encoded characters.
* @property {number} STRUCT - A multifield type.
* @property {number} MAP - A collection type (map/associative-array/dictionary).
* @property {number} SET - A collection type (unordered and without repeated values).
* @property {number} LIST - A collection type (unordered).
* @property {number} UTF8 - Array of bytes representing a string of UTF8 encoded characters.
* @property {number} UTF16 - Array of bytes representing a string of UTF16 encoded characters.
*/
interface Type {
'STOP': number;
'VOID': number;
'BOOL': number;
'BYTE': number;
'I08': number;
'DOUBLE': number;
'I16': number;
'I32': number;
'I64': number;
'STRING': number;
'UTF7': number;
'STRUCT': number;
'MAP': number;
'SET': number;
'LIST': number;
'UTF8': number;
'UTF16': number;
}
var Type: Type;
/**
* Thrift RPC message type string to Id mapping.
* @property {number} CALL - RPC call sent from client to server.
* @property {number} REPLY - RPC call normal response from server to client.
* @property {number} EXCEPTION - RPC call exception response from server to client.
* @property {number} ONEWAY - Oneway RPC call from client to server with no response.
*/
interface MessageType {
'CALL': number;
'REPLY': number;
'EXCEPTION': number;
'ONEWAY': number;
}
var MessageType: MessageType;
/**
* Utility function returning the count of an object's own properties.
* @param {object} obj - Object to test.
* @returns {number} number of object's own properties
*/
function objectLength(obj: Object): number;
/**
* Utility function to establish prototype inheritance.
* @param {function} constructor - Contstructor function to set as derived.
* @param {function} superConstructor - Contstructor function to set as base.
* @param {string} [name] - Type name to set as name property in derived prototype.
*/
function inherits(constructor: Function, superConstructor: Function, name?: string): void;
/**
* TException is the base class for all Thrift exceptions types.
*/
class TException implements Error {
name: string;
message: string;
/**
* Initializes a Thrift TException instance.
* @param {string} message - The TException message (distinct from the Error message).
*/
constructor(message: string);
/**
* Returns the message set on the exception.
* @returns {string} exception message
*/
getMessage(): string;
}
/**
* Thrift Application Exception type string to Id mapping.
* @property {number} UNKNOWN - Unknown/undefined.
* @property {number} UNKNOWN_METHOD - Client attempted to call a method unknown to the server.
* @property {number} INVALID_MESSAGE_TYPE - Client passed an unknown/unsupported MessageType.
* @property {number} WRONG_METHOD_NAME - Unused.
* @property {number} BAD_SEQUENCE_ID - Unused in Thrift RPC, used to flag proprietary sequence number errors.
* @property {number} MISSING_RESULT - Raised by a server processor if a handler fails to supply the required return result.
* @property {number} INTERNAL_ERROR - Something bad happened.
* @property {number} PROTOCOL_ERROR - The protocol layer failed to serialize or deserialize data.
* @property {number} INVALID_TRANSFORM - Unused.
* @property {number} INVALID_PROTOCOL - The protocol (or version) is not supported.
* @property {number} UNSUPPORTED_CLIENT_TYPE - Unused.
*/
interface TApplicationExceptionType {
'UNKNOWN': number;
'UNKNOWN_METHOD': number;
'INVALID_MESSAGE_TYPE': number;
'WRONG_METHOD_NAME': number;
'BAD_SEQUENCE_ID': number;
'MISSING_RESULT': number;
'INTERNAL_ERROR': number;
'PROTOCOL_ERROR': number;
'INVALID_TRANSFORM': number;
'INVALID_PROTOCOL': number;
'UNSUPPORTED_CLIENT_TYPE': number;
}
var TApplicationExceptionType: TApplicationExceptionType;
/**
* TApplicationException is the exception class used to propagate exceptions from an RPC server back to a calling client.
*/
class TApplicationException extends TException {
message: string;
code: number;
/**
* Initializes a Thrift TApplicationException instance.
* @param {string} message - The TApplicationException message (distinct from the Error message).
* @param {Thrift.TApplicationExceptionType} [code] - The TApplicationExceptionType code.
*/
constructor(message: string, code?: number);
/**
* Read a TApplicationException from the supplied protocol.
* @param {object} input - The input protocol to read from.
*/
read(input: Object): void;
/**
* Write a TApplicationException to the supplied protocol.
* @param {object} output - The output protocol to write to.
*/
write(output: Object): void;
/**
* Returns the application exception code set on the exception.
* @returns {Thrift.TApplicationExceptionType} exception code
*/
getCode(): number;
}
/**
* The Apache Thrift Transport layer performs byte level I/O between RPC
* clients and servers. The JavaScript Transport object type uses Http[s]/XHR and is
* the sole browser based Thrift transport. Target servers must implement the http[s]
* transport (see: node.js example server).
*/
class TXHRTransport {
url: string;
wpos: number;
rpos: number;
useCORS: any;
send_buf: string;
recv_buf: string;
/**
* If you do not specify a url then you must handle XHR operations on
* your own. This type can also be constructed using the Transport alias
* for backward compatibility.
* @param {string} [url] - The URL to connect to.
* @param {object} [options] - Options.
*/
constructor(url?: string, options?: Object);
/**
* Gets the browser specific XmlHttpRequest Object.
* @returns {object} the browser XHR interface object
*/
getXmlHttpRequestObject(): Object;
/**
* Sends the current XRH request if the transport was created with a URL and
* the async parameter if false. If the transport was not created with a URL
* or the async parameter is True or the URL is an empty string, the current
* send buffer is returned.
* @param {object} async - If true the current send buffer is returned.
* @param {function} callback - Optional async completion callback.
* @returns {undefined|string} Nothing or the current send buffer.
*/
flush(async: any, callback?: Function): string;
/**
* Creates a jQuery XHR object to be used for a Thrift server call.
* @param {object} client - The Thrift Service client object generated by the IDL compiler.
* @param {object} postData - The message to send to the server.
* @param {function} args - The function to call if the request succeeds.
* @param {function} recv_method - The Thrift Service Client receive method for the call.
* @returns {object} A new jQuery XHR object.
*/
jqRequest(client: Object, postData: any, args: Function, recv_method: Function): Object;
/**
* Sets the buffer to use when receiving server responses.
* @param {string} buf - The buffer to receive server responses.
*/
setRecvBuffer(buf: string): void;
/**
* Returns true if the transport is open, in browser based JavaScript
* this function always returns true.
* @returns {boolean} Always True.
*/
isOpen(): boolean;
/**
* Opens the transport connection, in browser based JavaScript
* this function is a nop.
*/
open(): void;
/**
* Closes the transport connection, in browser based JavaScript
* this function is a nop.
*/
close(): void;
/**
* Returns the specified number of characters from the response
* buffer.
* @param {number} len - The number of characters to return.
* @returns {string} Characters sent by the server.
*/
read(len: number): string;
/**
* Returns the entire response buffer.
* @returns {string} Characters sent by the server.
*/
readAll(): string;
/**
* Sets the send buffer to buf.
* @param {string} buf - The buffer to send.
*/
write(buf: string): void;
/**
* Returns the send buffer.
* @returns {string} The send buffer.
*/
getSendBuffer(): string;
}
}
}