Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | declare module Thrift { |
| 21 | /** |
| 22 | * Thrift JavaScript library version. |
| 23 | */ |
| 24 | var Version: string; |
| 25 | |
| 26 | /** |
| 27 | * Thrift IDL type string to Id mapping. |
| 28 | * @property {number} STOP - End of a set of fields. |
| 29 | * @property {number} VOID - No value (only legal for return types). |
| 30 | * @property {number} BOOL - True/False integer. |
| 31 | * @property {number} BYTE - Signed 8 bit integer. |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 32 | * @property {number} I08 - Signed 8 bit integer. |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 33 | * @property {number} DOUBLE - 64 bit IEEE 854 floating point. |
| 34 | * @property {number} I16 - Signed 16 bit integer. |
| 35 | * @property {number} I32 - Signed 32 bit integer. |
| 36 | * @property {number} I64 - Signed 64 bit integer. |
| 37 | * @property {number} STRING - Array of bytes representing a string of characters. |
| 38 | * @property {number} UTF7 - Array of bytes representing a string of UTF7 encoded characters. |
| 39 | * @property {number} STRUCT - A multifield type. |
| 40 | * @property {number} MAP - A collection type (map/associative-array/dictionary). |
| 41 | * @property {number} SET - A collection type (unordered and without repeated values). |
| 42 | * @property {number} LIST - A collection type (unordered). |
| 43 | * @property {number} UTF8 - Array of bytes representing a string of UTF8 encoded characters. |
| 44 | * @property {number} UTF16 - Array of bytes representing a string of UTF16 encoded characters. |
| 45 | */ |
| 46 | interface Type { |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 47 | STOP: number; |
| 48 | VOID: number; |
| 49 | BOOL: number; |
| 50 | BYTE: number; |
| 51 | I08: number; |
| 52 | DOUBLE: number; |
| 53 | I16: number; |
| 54 | I32: number; |
| 55 | I64: number; |
| 56 | STRING: number; |
| 57 | UTF7: number; |
| 58 | STRUCT: number; |
| 59 | MAP: number; |
| 60 | SET: number; |
| 61 | LIST: number; |
| 62 | UTF8: number; |
| 63 | UTF16: number; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 64 | } |
| 65 | var Type: Type; |
| 66 | |
| 67 | /** |
| 68 | * Thrift RPC message type string to Id mapping. |
| 69 | * @property {number} CALL - RPC call sent from client to server. |
| 70 | * @property {number} REPLY - RPC call normal response from server to client. |
| 71 | * @property {number} EXCEPTION - RPC call exception response from server to client. |
| 72 | * @property {number} ONEWAY - Oneway RPC call from client to server with no response. |
| 73 | */ |
| 74 | interface MessageType { |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 75 | CALL: number; |
| 76 | REPLY: number; |
| 77 | EXCEPTION: number; |
| 78 | ONEWAY: number; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 79 | } |
| 80 | var MessageType: MessageType; |
| 81 | |
| 82 | /** |
| 83 | * Utility function returning the count of an object's own properties. |
| 84 | * @param {object} obj - Object to test. |
| 85 | * @returns {number} number of object's own properties |
| 86 | */ |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 87 | function objectLength(obj: Object): number; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 88 | |
| 89 | /** |
| 90 | * Utility function to establish prototype inheritance. |
| 91 | * @param {function} constructor - Contstructor function to set as derived. |
| 92 | * @param {function} superConstructor - Contstructor function to set as base. |
| 93 | * @param {string} [name] - Type name to set as name property in derived prototype. |
| 94 | */ |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 95 | function inherits( |
| 96 | constructor: Function, |
| 97 | superConstructor: Function, |
| 98 | name?: string, |
| 99 | ): void; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 100 | |
| 101 | /** |
| 102 | * TException is the base class for all Thrift exceptions types. |
| 103 | */ |
| 104 | class TException implements Error { |
| 105 | name: string; |
| 106 | message: string; |
| 107 | |
| 108 | /** |
| 109 | * Initializes a Thrift TException instance. |
| 110 | * @param {string} message - The TException message (distinct from the Error message). |
| 111 | */ |
| 112 | constructor(message: string); |
| 113 | |
| 114 | /** |
| 115 | * Returns the message set on the exception. |
| 116 | * @returns {string} exception message |
| 117 | */ |
| 118 | getMessage(): string; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Thrift Application Exception type string to Id mapping. |
| 123 | * @property {number} UNKNOWN - Unknown/undefined. |
| 124 | * @property {number} UNKNOWN_METHOD - Client attempted to call a method unknown to the server. |
| 125 | * @property {number} INVALID_MESSAGE_TYPE - Client passed an unknown/unsupported MessageType. |
| 126 | * @property {number} WRONG_METHOD_NAME - Unused. |
| 127 | * @property {number} BAD_SEQUENCE_ID - Unused in Thrift RPC, used to flag proprietary sequence number errors. |
| 128 | * @property {number} MISSING_RESULT - Raised by a server processor if a handler fails to supply the required return result. |
| 129 | * @property {number} INTERNAL_ERROR - Something bad happened. |
| 130 | * @property {number} PROTOCOL_ERROR - The protocol layer failed to serialize or deserialize data. |
| 131 | * @property {number} INVALID_TRANSFORM - Unused. |
| 132 | * @property {number} INVALID_PROTOCOL - The protocol (or version) is not supported. |
| 133 | * @property {number} UNSUPPORTED_CLIENT_TYPE - Unused. |
| 134 | */ |
| 135 | interface TApplicationExceptionType { |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 136 | UNKNOWN: number; |
| 137 | UNKNOWN_METHOD: number; |
| 138 | INVALID_MESSAGE_TYPE: number; |
| 139 | WRONG_METHOD_NAME: number; |
| 140 | BAD_SEQUENCE_ID: number; |
| 141 | MISSING_RESULT: number; |
| 142 | INTERNAL_ERROR: number; |
| 143 | PROTOCOL_ERROR: number; |
| 144 | INVALID_TRANSFORM: number; |
| 145 | INVALID_PROTOCOL: number; |
| 146 | UNSUPPORTED_CLIENT_TYPE: number; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 147 | } |
| 148 | var TApplicationExceptionType: TApplicationExceptionType; |
| 149 | |
| 150 | /** |
| 151 | * TApplicationException is the exception class used to propagate exceptions from an RPC server back to a calling client. |
| 152 | */ |
| 153 | class TApplicationException extends TException { |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 154 | message: string; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 155 | code: number; |
| 156 | |
| 157 | /** |
| 158 | * Initializes a Thrift TApplicationException instance. |
| 159 | * @param {string} message - The TApplicationException message (distinct from the Error message). |
| 160 | * @param {Thrift.TApplicationExceptionType} [code] - The TApplicationExceptionType code. |
| 161 | */ |
| 162 | constructor(message: string, code?: number); |
| 163 | |
| 164 | /** |
| 165 | * Read a TApplicationException from the supplied protocol. |
| 166 | * @param {object} input - The input protocol to read from. |
| 167 | */ |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 168 | read(input: Object): void; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 169 | |
| 170 | /** |
| 171 | * Write a TApplicationException to the supplied protocol. |
| 172 | * @param {object} output - The output protocol to write to. |
| 173 | */ |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 174 | write(output: Object): void; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 175 | |
| 176 | /** |
| 177 | * Returns the application exception code set on the exception. |
| 178 | * @returns {Thrift.TApplicationExceptionType} exception code |
| 179 | */ |
| 180 | getCode(): number; |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * The Apache Thrift Transport layer performs byte level I/O between RPC |
| 185 | * clients and servers. The JavaScript Transport object type uses Http[s]/XHR and is |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 186 | * the sole browser based Thrift transport. Target servers must implement the http[s] |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 187 | * transport (see: node.js example server). |
| 188 | */ |
| 189 | class TXHRTransport { |
| 190 | url: string; |
| 191 | wpos: number; |
| 192 | rpos: number; |
| 193 | useCORS: any; |
| 194 | send_buf: string; |
| 195 | recv_buf: string; |
| 196 | |
| 197 | /** |
| 198 | * If you do not specify a url then you must handle XHR operations on |
| 199 | * your own. This type can also be constructed using the Transport alias |
| 200 | * for backward compatibility. |
| 201 | * @param {string} [url] - The URL to connect to. |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 202 | * @param {object} [options] - Options. |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 203 | */ |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 204 | constructor(url?: string, options?: Object); |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 205 | |
| 206 | /** |
| 207 | * Gets the browser specific XmlHttpRequest Object. |
| 208 | * @returns {object} the browser XHR interface object |
| 209 | */ |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 210 | getXmlHttpRequestObject(): Object; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * Sends the current XRH request if the transport was created with a URL and |
| 214 | * the async parameter if false. If the transport was not created with a URL |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 215 | * or the async parameter is True or the URL is an empty string, the current |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 216 | * send buffer is returned. |
| 217 | * @param {object} async - If true the current send buffer is returned. |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 218 | * @param {function} callback - Optional async completion callback. |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 219 | * @returns {undefined|string} Nothing or the current send buffer. |
| 220 | */ |
| 221 | flush(async: any, callback?: Function): string; |
| 222 | |
| 223 | /** |
| 224 | * Creates a jQuery XHR object to be used for a Thrift server call. |
| 225 | * @param {object} client - The Thrift Service client object generated by the IDL compiler. |
| 226 | * @param {object} postData - The message to send to the server. |
Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 227 | * @param {function} args - The function to call if the request succeeds. |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 228 | * @param {function} recv_method - The Thrift Service Client receive method for the call. |
| 229 | * @returns {object} A new jQuery XHR object. |
| 230 | */ |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 231 | jqRequest( |
| 232 | client: Object, |
| 233 | postData: any, |
| 234 | args: Function, |
| 235 | recv_method: Function, |
| 236 | ): Object; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 237 | |
| 238 | /** |
| 239 | * Sets the buffer to use when receiving server responses. |
| 240 | * @param {string} buf - The buffer to receive server responses. |
| 241 | */ |
| 242 | setRecvBuffer(buf: string): void; |
| 243 | |
| 244 | /** |
| 245 | * Returns true if the transport is open, in browser based JavaScript |
| 246 | * this function always returns true. |
| 247 | * @returns {boolean} Always True. |
| 248 | */ |
| 249 | isOpen(): boolean; |
| 250 | |
| 251 | /** |
| 252 | * Opens the transport connection, in browser based JavaScript |
| 253 | * this function is a nop. |
| 254 | */ |
| 255 | open(): void; |
| 256 | |
| 257 | /** |
| 258 | * Closes the transport connection, in browser based JavaScript |
| 259 | * this function is a nop. |
| 260 | */ |
| 261 | close(): void; |
| 262 | |
| 263 | /** |
| 264 | * Returns the specified number of characters from the response |
| 265 | * buffer. |
| 266 | * @param {number} len - The number of characters to return. |
| 267 | * @returns {string} Characters sent by the server. |
| 268 | */ |
| 269 | read(len: number): string; |
| 270 | |
| 271 | /** |
| 272 | * Returns the entire response buffer. |
| 273 | * @returns {string} Characters sent by the server. |
| 274 | */ |
| 275 | readAll(): string; |
| 276 | |
| 277 | /** |
| 278 | * Sets the send buffer to buf. |
| 279 | * @param {string} buf - The buffer to send. |
| 280 | */ |
| 281 | write(buf: string): void; |
| 282 | |
| 283 | /** |
| 284 | * Returns the send buffer. |
| 285 | * @returns {string} The send buffer. |
| 286 | */ |
| 287 | getSendBuffer(): string; |
| 288 | } |
| 289 | |
| 290 | /** |
| 291 | * Old alias of the TXHRTransport for backwards compatibility. |
| 292 | */ |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 293 | class Transport extends TXHRTransport {} |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 294 | |
| 295 | /** |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 296 | * The Apache Thrift Transport layer performs byte level I/O |
| 297 | * between RPC clients and servers. The JavaScript TWebSocketTransport object |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 298 | * uses the WebSocket protocol. Target servers must implement WebSocket. |
| 299 | */ |
| 300 | class TWebSocketTransport { |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 301 | url: string; //Where to connect |
| 302 | socket: any; //The web socket |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 303 | callbacks: Function[]; //Pending callbacks |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 304 | send_pending: any[]; //Buffers/Callback pairs waiting to be sent |
| 305 | send_buf: string; //Outbound data, immutable until sent |
| 306 | recv_buf: string; //Inbound data |
| 307 | rb_wpos: number; //Network write position in receive buffer |
| 308 | rb_rpos: number; //Client read position in receive buffer |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 309 | |
| 310 | /** |
| 311 | * Constructor Function for the WebSocket transport. |
| 312 | * @param {string } [url] - The URL to connect to. |
| 313 | */ |
| 314 | constructor(url: string); |
| 315 | |
Jens Geyer | 356f7aa | 2016-01-30 11:34:29 +0100 | [diff] [blame] | 316 | __reset(url: string): void; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 317 | |
| 318 | /** |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 319 | * Sends the current WS request and registers callback. The async |
| 320 | * parameter is ignored (WS flush is always async) and the callback |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 321 | * function parameter is required. |
| 322 | * @param {object} async - Ignored. |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 323 | * @param {function} callback - The client completion callback. |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 324 | * @returns {undefined|string} Nothing (undefined) |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 325 | */ |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 326 | flush(async: any, callback: Function): string; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 327 | |
| 328 | __onOpen(): void; |
| 329 | |
| 330 | __onClose(): void; |
| 331 | |
| 332 | __onMessage(): void; |
| 333 | |
| 334 | __onError(): void; |
| 335 | |
| 336 | /** |
| 337 | * Sets the buffer to use when receiving server responses. |
| 338 | * @param {string} buf - The buffer to receive server responses. |
| 339 | */ |
| 340 | setRecvBuffer(buf: string): void; |
| 341 | |
| 342 | /** |
| 343 | * Returns true if the transport is open |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 344 | * @returns {boolean} |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 345 | */ |
| 346 | isOpen(): boolean; |
| 347 | |
| 348 | /** |
| 349 | * Opens the transport connection |
| 350 | */ |
| 351 | open(): void; |
| 352 | |
| 353 | /** |
| 354 | * Closes the transport connection |
| 355 | */ |
| 356 | close(): void; |
| 357 | |
| 358 | /** |
| 359 | * Returns the specified number of characters from the response |
| 360 | * buffer. |
| 361 | * @param {number} len - The number of characters to return. |
| 362 | * @returns {string} Characters sent by the server. |
| 363 | */ |
| 364 | read(len: number): string; |
| 365 | |
| 366 | /** |
| 367 | * Returns the entire response buffer. |
| 368 | * @returns {string} Characters sent by the server. |
| 369 | */ |
| 370 | readAll(): string; |
| 371 | |
| 372 | /** |
| 373 | * Sets the send buffer to buf. |
| 374 | * @param {string} buf - The buffer to send. |
| 375 | */ |
| 376 | write(buf: string): void; |
| 377 | |
| 378 | /** |
| 379 | * Returns the send buffer. |
| 380 | * @returns {string} The send buffer. |
| 381 | */ |
| 382 | getSendBuffer(): string; |
| 383 | } |
| 384 | |
| 385 | /** |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 386 | * Apache Thrift Protocols perform serialization which enables cross |
| 387 | * language RPC. The Protocol type is the JavaScript browser implementation |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 388 | * of the Apache Thrift TJSONProtocol. |
| 389 | */ |
| 390 | class TJSONProtocol { |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 391 | transport: Object; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 392 | |
| 393 | /** |
| 394 | * Thrift IDL type Id to string mapping. |
| 395 | * The mapping table looks as follows: |
| 396 | * Thrift.Type.BOOL -> "tf": True/False integer. |
| 397 | * Thrift.Type.BYTE -> "i8": Signed 8 bit integer. |
| 398 | * Thrift.Type.I16 -> "i16": Signed 16 bit integer. |
| 399 | * Thrift.Type.I32 -> "i32": Signed 32 bit integer. |
| 400 | * Thrift.Type.I64 -> "i64": Signed 64 bit integer. |
| 401 | * Thrift.Type.DOUBLE -> "dbl": 64 bit IEEE 854 floating point. |
| 402 | * Thrift.Type.STRUCT -> "rec": A multifield type. |
| 403 | * Thrift.Type.STRING -> "str": Array of bytes representing a string of characters. |
| 404 | * Thrift.Type.MAP -> "map": A collection type (map/associative-array/dictionary). |
| 405 | * Thrift.Type.LIST -> "lst": A collection type (unordered). |
| 406 | * Thrift.Type.SET -> "set": A collection type (unordered and without repeated values). |
| 407 | */ |
| 408 | Type: { [k: number]: string }; |
| 409 | |
| 410 | /** |
| 411 | * Thrift IDL type string to Id mapping. |
| 412 | * The mapping table looks as follows: |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 413 | * "tf" -> Thrift.Type.BOOL |
| 414 | * "i8" -> Thrift.Type.BYTE |
| 415 | * "i16" -> Thrift.Type.I16 |
| 416 | * "i32" -> Thrift.Type.I32 |
| 417 | * "i64" -> Thrift.Type.I64 |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 418 | * "dbl" -> Thrift.Type.DOUBLE |
| 419 | * "rec" -> Thrift.Type.STRUCT |
| 420 | * "str" -> Thrift.Type.STRING |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 421 | * "map" -> Thrift.Type.MAP |
| 422 | * "lst" -> Thrift.Type.LIST |
| 423 | * "set" -> Thrift.Type.SET |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 424 | */ |
| 425 | RType: { [k: string]: number }; |
| 426 | |
| 427 | /** |
| 428 | * The TJSONProtocol version number. |
| 429 | */ |
| 430 | Version: number; |
| 431 | |
| 432 | /** |
| 433 | * Initializes a Thrift JSON protocol instance. |
| 434 | * @param {Thrift.Transport} transport - The transport to serialize to/from. |
| 435 | */ |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 436 | constructor(transport: Object); |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 437 | |
| 438 | /** |
| 439 | * Returns the underlying transport. |
| 440 | * @returns {Thrift.Transport} The underlying transport. |
| 441 | */ |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 442 | getTransport(): Object; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 443 | |
| 444 | /** |
| 445 | * Serializes the beginning of a Thrift RPC message. |
| 446 | * @param {string} name - The service method to call. |
| 447 | * @param {Thrift.MessageType} messageType - The type of method call. |
| 448 | * @param {number} seqid - The sequence number of this call (always 0 in Apache Thrift). |
| 449 | */ |
| 450 | writeMessageBegin(name: string, messageType: number, seqid: number): void; |
| 451 | |
| 452 | /** |
| 453 | * Serializes the end of a Thrift RPC message. |
| 454 | */ |
| 455 | writeMessageEnd(): void; |
| 456 | |
| 457 | /** |
| 458 | * Serializes the beginning of a struct. |
| 459 | * @param {string} name - The name of the struct. |
| 460 | */ |
| 461 | writeStructBegin(name?: string): void; |
| 462 | |
| 463 | /** |
| 464 | * Serializes the end of a struct. |
| 465 | */ |
| 466 | writeStructEnd(): void; |
| 467 | |
| 468 | /** |
| 469 | * Serializes the beginning of a struct field. |
| 470 | * @param {string} name - The name of the field. |
| 471 | * @param {Thrift.Protocol.Type} fieldType - The data type of the field. |
| 472 | * @param {number} fieldId - The field's unique identifier. |
| 473 | */ |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 474 | writeFieldBegin(name: string, fieldType: number, fieldId: number): void; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 475 | |
| 476 | /** |
| 477 | * Serializes the end of a field. |
| 478 | */ |
| 479 | writeFieldEnd(): void; |
| 480 | |
| 481 | /** |
| 482 | * Serializes the end of the set of fields for a struct. |
| 483 | */ |
| 484 | writeFieldStop(): void; |
| 485 | |
| 486 | /** |
| 487 | * Serializes the beginning of a map collection. |
| 488 | * @param {Thrift.Type} keyType - The data type of the key. |
| 489 | * @param {Thrift.Type} valType - The data type of the value. |
| 490 | * @param {number} [size] - The number of elements in the map (ignored). |
| 491 | */ |
| 492 | writeMapBegin(keyType: number, valType: number, size?: number): void; |
| 493 | |
| 494 | /** |
| 495 | * Serializes the end of a map. |
| 496 | */ |
| 497 | writeMapEnd(): void; |
| 498 | |
| 499 | /** |
| 500 | * Serializes the beginning of a list collection. |
| 501 | * @param {Thrift.Type} elemType - The data type of the elements. |
| 502 | * @param {number} size - The number of elements in the list. |
| 503 | */ |
| 504 | writeListBegin(elemType: number, size: number): void; |
| 505 | |
| 506 | /** |
| 507 | * Serializes the end of a list. |
| 508 | */ |
| 509 | writeListEnd(): void; |
| 510 | |
| 511 | /** |
| 512 | * Serializes the beginning of a set collection. |
| 513 | * @param {Thrift.Type} elemType - The data type of the elements. |
| 514 | * @param {number} size - The number of elements in the list. |
| 515 | */ |
| 516 | writeSetBegin(elemType: number, size: number): void; |
| 517 | |
| 518 | /** |
| 519 | * Serializes the end of a set. |
| 520 | */ |
| 521 | writeSetEnd(): void; |
| 522 | |
| 523 | /** Serializes a boolean */ |
| 524 | writeBool(value: boolean): void; |
| 525 | |
| 526 | /** Serializes a number */ |
| 527 | writeByte(i8: number): void; |
| 528 | |
| 529 | /** Serializes a number */ |
| 530 | writeI16(i16: number): void; |
| 531 | |
| 532 | /** Serializes a number */ |
| 533 | writeI32(i32: number): void; |
| 534 | |
| 535 | /** Serializes a number */ |
| 536 | writeI64(i64: number): void; |
| 537 | |
| 538 | /** Serializes a number */ |
| 539 | writeDouble(dbl: number): void; |
| 540 | |
| 541 | /** Serializes a string */ |
| 542 | writeString(str: string): void; |
| 543 | |
| 544 | /** Serializes a string */ |
| 545 | writeBinary(str: string): void; |
| 546 | |
| 547 | /** |
| 548 | @class |
| 549 | @name AnonReadMessageBeginReturn |
| 550 | @property {string} fname - The name of the service method. |
| 551 | @property {Thrift.MessageType} mtype - The type of message call. |
| 552 | @property {number} rseqid - The sequence number of the message (0 in Thrift RPC). |
| 553 | */ |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 554 | /** |
| 555 | * Deserializes the beginning of a message. |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 556 | * @returns {AnonReadMessageBeginReturn} |
| 557 | */ |
| 558 | readMessageBegin(): { fname: string; mtype: number; rseqid: number }; |
| 559 | |
| 560 | /** Deserializes the end of a message. */ |
| 561 | readMessageEnd(): void; |
| 562 | |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 563 | /** |
| 564 | * Deserializes the beginning of a struct. |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 565 | * @param {string} [name] - The name of the struct (ignored). |
| 566 | * @returns {object} - An object with an empty string fname property. |
| 567 | */ |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 568 | readStructBegin(name?: string): { fname: string }; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 569 | |
| 570 | /** Deserializes the end of a struct. */ |
| 571 | readStructEnd(): void; |
| 572 | |
| 573 | /** |
| 574 | @class |
| 575 | @name AnonReadFieldBeginReturn |
| 576 | @property {string} fname - The name of the field (always ''). |
| 577 | @property {Thrift.Type} ftype - The data type of the field. |
| 578 | @property {number} fid - The unique identifier of the field. |
| 579 | */ |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 580 | /** |
| 581 | * Deserializes the beginning of a field. |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 582 | * @returns {AnonReadFieldBeginReturn} |
| 583 | */ |
| 584 | readFieldBegin(): { fname: string; ftype: number; fid: number }; |
| 585 | |
| 586 | /** Deserializes the end of a field. */ |
| 587 | readFieldEnd(): void; |
| 588 | |
| 589 | /** |
| 590 | @class |
| 591 | @name AnonReadMapBeginReturn |
| 592 | @property {Thrift.Type} ktype - The data type of the key. |
| 593 | @property {Thrift.Type} vtype - The data type of the value. |
| 594 | @property {number} size - The number of elements in the map. |
| 595 | */ |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 596 | /** |
| 597 | * Deserializes the beginning of a map. |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 598 | * @returns {AnonReadMapBeginReturn} |
| 599 | */ |
| 600 | readMapBegin(): { ktype: number; vtype: number; size: number }; |
| 601 | |
| 602 | /** Deserializes the end of a map. */ |
| 603 | readMapEnd(): void; |
| 604 | |
| 605 | /** |
| 606 | @class |
| 607 | @name AnonReadColBeginReturn |
| 608 | @property {Thrift.Type} etype - The data type of the element. |
| 609 | @property {number} size - The number of elements in the collection. |
| 610 | */ |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 611 | /** |
| 612 | * Deserializes the beginning of a list. |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 613 | * @returns {AnonReadColBeginReturn} |
| 614 | */ |
| 615 | readListBegin(): { etype: number; size: number }; |
| 616 | |
| 617 | /** Deserializes the end of a list. */ |
| 618 | readListEnd(): void; |
| 619 | |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 620 | /** |
| 621 | * Deserializes the beginning of a set. |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 622 | * @param {Thrift.Type} elemType - The data type of the elements (ignored). |
| 623 | * @param {number} size - The number of elements in the list (ignored). |
| 624 | * @returns {AnonReadColBeginReturn} |
| 625 | */ |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 626 | readSetBegin( |
| 627 | elemType?: number, |
| 628 | size?: number, |
| 629 | ): { etype: number; size: number }; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 630 | |
| 631 | /** Deserializes the end of a set. */ |
| 632 | readSetEnd(): void; |
| 633 | |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 634 | /** Returns an object with a value property set to |
| 635 | * False unless the next number in the protocol buffer |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 636 | * is 1, in which case the value property is True. */ |
| 637 | readBool(): Object; |
| 638 | |
| 639 | /** Returns an object with a value property set to the |
| 640 | next value found in the protocol buffer. */ |
| 641 | readByte(): Object; |
| 642 | |
| 643 | /** Returns an object with a value property set to the |
| 644 | next value found in the protocol buffer. */ |
| 645 | readI16(): Object; |
| 646 | |
| 647 | /** Returns an object with a value property set to the |
| 648 | next value found in the protocol buffer. */ |
| 649 | readI32(f?: any): Object; |
| 650 | |
| 651 | /** Returns an object with a value property set to the |
| 652 | next value found in the protocol buffer. */ |
| 653 | readI64(): Object; |
| 654 | |
| 655 | /** Returns an object with a value property set to the |
| 656 | next value found in the protocol buffer. */ |
| 657 | readDouble(): Object; |
| 658 | |
| 659 | /** Returns an object with a value property set to the |
| 660 | next value found in the protocol buffer. */ |
| 661 | readString(): Object; |
| 662 | |
| 663 | /** Returns an object with a value property set to the |
| 664 | next value found in the protocol buffer. */ |
| 665 | readBinary(): Object; |
| 666 | |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 667 | /** |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 668 | * Method to arbitrarily skip over data (not implemented). |
| 669 | */ |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 670 | skip(type: number): void; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 671 | } |
| 672 | |
| 673 | /** |
| 674 | * Old alias of the TXHRTransport for backwards compatibility. |
| 675 | */ |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 676 | class Protocol extends TJSONProtocol {} |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 677 | |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 678 | class MultiplexProtocol extends TJSONProtocol { |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 679 | serviceName: string; |
| 680 | |
| 681 | /** |
| 682 | * Initializes a MutilplexProtocol Implementation as a Wrapper for Thrift.Protocol. |
| 683 | * @param {string} srvName |
| 684 | * @param {Thrift.Transport} trans |
| 685 | * @param {any} [strictRead] |
| 686 | * @param {any} [strictWrite] |
| 687 | */ |
Cameron Martin | caef0ed | 2025-01-15 11:58:39 +0100 | [diff] [blame^] | 688 | constructor( |
| 689 | srvName: string, |
| 690 | trans: Object, |
| 691 | strictRead?: any, |
| 692 | strictWrite?: any, |
| 693 | ); |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 694 | |
| 695 | /** |
| 696 | * Override writeMessageBegin method of prototype |
| 697 | * Serializes the beginning of a Thrift RPC message. |
| 698 | * @param {string} name - The service method to call. |
| 699 | * @param {Thrift.MessageType} messageType - The type of method call. |
| 700 | * @param {number} seqid - The sequence number of this call (always 0 in Apache Thrift). |
| 701 | */ |
| 702 | writeMessageBegin(name: string, type: number, seqid: number): void; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | class Multiplexer { |
| 706 | seqid: number; |
| 707 | |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 708 | /** |
| 709 | * Instantiates a multiplexed client for a specific service. |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 710 | * @param {String} serviceName - The transport to serialize to/from. |
| 711 | * @param {Thrift.ServiceClient} SCl - The Service Client Class. |
| 712 | * @param {Thrift.Transport} transport - Thrift.Transport instance which provides remote host:port. |
Kirby1337 | 6d9a3ca | 2014-12-18 16:41:10 +0100 | [diff] [blame] | 713 | */ |
Jens Geyer | 356f7aa | 2016-01-30 11:34:29 +0100 | [diff] [blame] | 714 | createClient(serviceName: string, SCl: any, transport: Object): any; |
Pascal Schweizer | ada1016 | 2014-03-21 17:18:59 +0100 | [diff] [blame] | 715 | } |
Jens Geyer | 356f7aa | 2016-01-30 11:34:29 +0100 | [diff] [blame] | 716 | } |