├── .gitignore ├── examples ├── query.js └── table_plugin.js ├── package.json ├── index.js ├── README.md ├── extension_server.js └── gen-nodejs ├── Extension.js ├── osquery_types.js └── ExtensionManager.js /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | .DS_Store 10 | 11 | tmp 12 | pids 13 | logs 14 | 15 | node_modules 16 | npm-debug.log 17 | 18 | -------------------------------------------------------------------------------- /examples/query.js: -------------------------------------------------------------------------------- 1 | var osquery = require('../index.js'); 2 | var os = osquery.createClient(); 3 | //os.query('select * from osquery_extensions', console.log); 4 | os.query('select * from node_ext_table', console.log); 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "osquery", 3 | "version": "1.0.0", 4 | "description": "facebook osquery client", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git://github.com/sidorares/osquery-node.git" 12 | }, 13 | "keywords": [ 14 | "osquery" 15 | ], 16 | "author": "Andrey Sidorov ", 17 | "license": "MIT", 18 | "readmeFilename": "README.md", 19 | "dependencies": { 20 | "thrift": "^0.9.2" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/table_plugin.js: -------------------------------------------------------------------------------- 1 | var osquery = require('../index.js'); 2 | 3 | var generateTable = function(req, resp) { 4 | resp(null, [{ 5 | "foo": "foo value", 6 | "bar": "bar value " + Date.now() 7 | }] 8 | ); 9 | }; 10 | 11 | var c = osquery.createClient(); 12 | var s = c.createServer({ 13 | info: { 14 | name: 'test table extension' 15 | }, 16 | plugins: [{ 17 | type: 'table', 18 | name: 'node_ext_table', 19 | schema: [ 20 | {"name": "foo", "type": "TEXT"}, 21 | {"name": "bar", "type": "TEXT"} 22 | ], 23 | handler: generateTable 24 | }] 25 | }); 26 | 27 | s.listen(function(err, serv) { 28 | console.log('extension started!'); 29 | }); 30 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var thrift = require('thrift'); 2 | 3 | var ExtensionManager = require('./gen-nodejs/ExtensionManager.js'); 4 | var Types = require('./gen-nodejs/osquery_types.js'); 5 | 6 | function Client(opts) { 7 | opts = opts || {}; 8 | var path = opts.path || '/Users/' + process.env.USER + '/.osquery/shell.em'; 9 | var conn = thrift.createConnection(0, path); 10 | this._em = thrift.createClient(ExtensionManager, conn); 11 | this._socketPath = path; 12 | } 13 | 14 | Client.prototype.query = function(sql, cb) { 15 | this._em.query(sql, cb); 16 | }; 17 | 18 | Client.prototype.addExtension = function() { 19 | 20 | }; 21 | 22 | module.exports.createClient = function(opts) { return new Client(opts); }; 23 | 24 | Client.prototype.createServer = function(opts) { 25 | var Server = require('./extension_server.js'); 26 | return new Server(this, opts); 27 | }; 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | osquery-node 2 | ============== 3 | 4 | Facebook [osquery](https://github.com/facebook/osquery) client for node.js 5 | 6 | ## Installation 7 | 8 | npm install osquery 9 | 10 | ## Usage 11 | 12 | client: 13 | 14 | ```js 15 | var osquery = require('osquery'); 16 | 17 | var os = osquery.createClient({ path: '/var/osquery/osquery.em' }); 18 | os.query('SELECT uid, name FROM listening_ports l, processes p WHERE l.pid=p.pid', function(err, res) { 19 | console.log(res); 20 | }); 21 | 22 | ``` 23 | 24 | Table plugin: 25 | 26 | ```js 27 | var osquery = require('osquery'); 28 | 29 | var generateTable = function(req, resp) { 30 | resp(null, [{ 31 | "foo": "foo value", 32 | "bar": "bar value " + Date.now() 33 | }] 34 | ); 35 | }; 36 | 37 | var c = osquery.createClient(); 38 | var s = c.createServer({ 39 | info: { 40 | name: 'test table extension' 41 | }, 42 | plugins: [{ 43 | type: 'table', 44 | name: 'node_ext_table', 45 | schema: [ 46 | {"name": "foo", "type": "TEXT"}, 47 | {"name": "bar", "type": "TEXT"} 48 | ], 49 | handler: generateTable 50 | }] 51 | }); 52 | 53 | s.listen(function(err, serv) { 54 | console.log('extension started!'); 55 | }); 56 | ``` 57 | 58 | ## License 59 | 60 | MIT 61 | 62 | ## See also 63 | - [mysql to osquery proxy](https://github.com/sidorares/mysql-osquery-proxy) 64 | - [python client](https://github.com/osquery/osquery-python) 65 | -------------------------------------------------------------------------------- /extension_server.js: -------------------------------------------------------------------------------- 1 | var thrift = require('thrift'); 2 | 3 | var Extension = require('./gen-nodejs/Extension.js'); 4 | var Types = require('./gen-nodejs/osquery_types.js'); 5 | 6 | var OK_STATUS = new Types.ExtensionStatus({ code: 0, message: 'OK' }); 7 | 8 | var Server = function(client, opts) { 9 | this._plugins = opts.plugins || []; 10 | this._info = new Types.InternalExtensionInfo(opts.info || {}); 11 | this._registry = {}; 12 | this._clientSocketPath = client._socketPath; 13 | this._em = client._em; 14 | var registry = this._registry; 15 | var self = this; 16 | self._handlers = {}; 17 | self._plugins.forEach(function(p) { 18 | if (!registry[p.type]) 19 | registry[p.type] = {}; 20 | if (p.type === 'table') { 21 | registry[p.type][p.name] = p.schema; 22 | } 23 | // TODO: other plugin types 24 | self._handlers[p.type + '_' + p.name] = p.handler; 25 | }); 26 | }; 27 | 28 | Server.prototype._callDispatcher = function(registry, item, request, result) { 29 | var handler = this._handlers[registry + '_' + item]; 30 | var resp; 31 | 32 | var respondWithError = function(err) { 33 | result(null, new Types.ExtensionResponse({ 34 | status: new Types.ExtensionStatus({ code: -1, message: err.message }) 35 | })); 36 | }; 37 | try { 38 | handler(request, function(err, data) { 39 | if (err) { 40 | return respondWithError(err); 41 | } 42 | result(null, new Types.ExtensionResponse({ 43 | status: OK_STATUS, 44 | response: data 45 | })); 46 | }); 47 | } catch(e) { 48 | respondWithError(e); 49 | } 50 | }; 51 | 52 | Server.prototype.listen = function(cb) { 53 | if (!cb) { 54 | cb = function(err) { 55 | if (err) throw err; 56 | }; 57 | } 58 | var self = this; 59 | this._em.registerExtension(this._info, this._registry, function(err, resp) { 60 | if (err) 61 | return cb(err); 62 | self._server = thrift.createServer(Extension, { 63 | ping: function(result) { 64 | result(null, OK_STATUS); 65 | }, 66 | call: Server.prototype._callDispatcher.bind(self) 67 | }, {transport: thrift.TBufferedTransport}); 68 | 69 | var socketPath = self._clientSocketPath + '.' + resp.uuid.toString(); 70 | self._server.listen(socketPath, function(err) { 71 | if (err) return cb(err); 72 | cb (null, self._server); 73 | }); 74 | }); 75 | }; 76 | 77 | module.exports = Server; 78 | -------------------------------------------------------------------------------- /gen-nodejs/Extension.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift Compiler (0.9.2) 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var thrift = require('thrift'); 7 | var Thrift = thrift.Thrift; 8 | var Q = thrift.Q; 9 | 10 | 11 | var ttypes = require('./osquery_types'); 12 | //HELPER FUNCTIONS AND STRUCTURES 13 | 14 | Extension_ping_args = function(args) { 15 | }; 16 | Extension_ping_args.prototype = {}; 17 | Extension_ping_args.prototype.read = function(input) { 18 | input.readStructBegin(); 19 | while (true) 20 | { 21 | var ret = input.readFieldBegin(); 22 | var fname = ret.fname; 23 | var ftype = ret.ftype; 24 | var fid = ret.fid; 25 | if (ftype == Thrift.Type.STOP) { 26 | break; 27 | } 28 | input.skip(ftype); 29 | input.readFieldEnd(); 30 | } 31 | input.readStructEnd(); 32 | return; 33 | }; 34 | 35 | Extension_ping_args.prototype.write = function(output) { 36 | output.writeStructBegin('Extension_ping_args'); 37 | output.writeFieldStop(); 38 | output.writeStructEnd(); 39 | return; 40 | }; 41 | 42 | Extension_ping_result = function(args) { 43 | this.success = null; 44 | if (args) { 45 | if (args.success !== undefined) { 46 | this.success = args.success; 47 | } 48 | } 49 | }; 50 | Extension_ping_result.prototype = {}; 51 | Extension_ping_result.prototype.read = function(input) { 52 | input.readStructBegin(); 53 | while (true) 54 | { 55 | var ret = input.readFieldBegin(); 56 | var fname = ret.fname; 57 | var ftype = ret.ftype; 58 | var fid = ret.fid; 59 | if (ftype == Thrift.Type.STOP) { 60 | break; 61 | } 62 | switch (fid) 63 | { 64 | case 0: 65 | if (ftype == Thrift.Type.STRUCT) { 66 | this.success = new ttypes.ExtensionStatus(); 67 | this.success.read(input); 68 | } else { 69 | input.skip(ftype); 70 | } 71 | break; 72 | case 0: 73 | input.skip(ftype); 74 | break; 75 | default: 76 | input.skip(ftype); 77 | } 78 | input.readFieldEnd(); 79 | } 80 | input.readStructEnd(); 81 | return; 82 | }; 83 | 84 | Extension_ping_result.prototype.write = function(output) { 85 | output.writeStructBegin('Extension_ping_result'); 86 | if (this.success !== null && this.success !== undefined) { 87 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 88 | this.success.write(output); 89 | output.writeFieldEnd(); 90 | } 91 | output.writeFieldStop(); 92 | output.writeStructEnd(); 93 | return; 94 | }; 95 | 96 | Extension_call_args = function(args) { 97 | this.registry = null; 98 | this.item = null; 99 | this.request = null; 100 | if (args) { 101 | if (args.registry !== undefined) { 102 | this.registry = args.registry; 103 | } 104 | if (args.item !== undefined) { 105 | this.item = args.item; 106 | } 107 | if (args.request !== undefined) { 108 | this.request = args.request; 109 | } 110 | } 111 | }; 112 | Extension_call_args.prototype = {}; 113 | Extension_call_args.prototype.read = function(input) { 114 | input.readStructBegin(); 115 | while (true) 116 | { 117 | var ret = input.readFieldBegin(); 118 | var fname = ret.fname; 119 | var ftype = ret.ftype; 120 | var fid = ret.fid; 121 | if (ftype == Thrift.Type.STOP) { 122 | break; 123 | } 124 | switch (fid) 125 | { 126 | case 1: 127 | if (ftype == Thrift.Type.STRING) { 128 | this.registry = input.readString(); 129 | } else { 130 | input.skip(ftype); 131 | } 132 | break; 133 | case 2: 134 | if (ftype == Thrift.Type.STRING) { 135 | this.item = input.readString(); 136 | } else { 137 | input.skip(ftype); 138 | } 139 | break; 140 | case 3: 141 | if (ftype == Thrift.Type.MAP) { 142 | var _size18 = 0; 143 | var _rtmp322; 144 | this.request = {}; 145 | var _ktype19 = 0; 146 | var _vtype20 = 0; 147 | _rtmp322 = input.readMapBegin(); 148 | _ktype19 = _rtmp322.ktype; 149 | _vtype20 = _rtmp322.vtype; 150 | _size18 = _rtmp322.size; 151 | for (var _i23 = 0; _i23 < _size18; ++_i23) 152 | { 153 | var key24 = null; 154 | var val25 = null; 155 | key24 = input.readString(); 156 | val25 = input.readString(); 157 | this.request[key24] = val25; 158 | } 159 | input.readMapEnd(); 160 | } else { 161 | input.skip(ftype); 162 | } 163 | break; 164 | default: 165 | input.skip(ftype); 166 | } 167 | input.readFieldEnd(); 168 | } 169 | input.readStructEnd(); 170 | return; 171 | }; 172 | 173 | Extension_call_args.prototype.write = function(output) { 174 | output.writeStructBegin('Extension_call_args'); 175 | if (this.registry !== null && this.registry !== undefined) { 176 | output.writeFieldBegin('registry', Thrift.Type.STRING, 1); 177 | output.writeString(this.registry); 178 | output.writeFieldEnd(); 179 | } 180 | if (this.item !== null && this.item !== undefined) { 181 | output.writeFieldBegin('item', Thrift.Type.STRING, 2); 182 | output.writeString(this.item); 183 | output.writeFieldEnd(); 184 | } 185 | if (this.request !== null && this.request !== undefined) { 186 | output.writeFieldBegin('request', Thrift.Type.MAP, 3); 187 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.STRING, Thrift.objectLength(this.request)); 188 | for (var kiter26 in this.request) 189 | { 190 | if (this.request.hasOwnProperty(kiter26)) 191 | { 192 | var viter27 = this.request[kiter26]; 193 | output.writeString(kiter26); 194 | output.writeString(viter27); 195 | } 196 | } 197 | output.writeMapEnd(); 198 | output.writeFieldEnd(); 199 | } 200 | output.writeFieldStop(); 201 | output.writeStructEnd(); 202 | return; 203 | }; 204 | 205 | Extension_call_result = function(args) { 206 | this.success = null; 207 | if (args) { 208 | if (args.success !== undefined) { 209 | this.success = args.success; 210 | } 211 | } 212 | }; 213 | Extension_call_result.prototype = {}; 214 | Extension_call_result.prototype.read = function(input) { 215 | input.readStructBegin(); 216 | while (true) 217 | { 218 | var ret = input.readFieldBegin(); 219 | var fname = ret.fname; 220 | var ftype = ret.ftype; 221 | var fid = ret.fid; 222 | if (ftype == Thrift.Type.STOP) { 223 | break; 224 | } 225 | switch (fid) 226 | { 227 | case 0: 228 | if (ftype == Thrift.Type.STRUCT) { 229 | this.success = new ttypes.ExtensionResponse(); 230 | this.success.read(input); 231 | } else { 232 | input.skip(ftype); 233 | } 234 | break; 235 | case 0: 236 | input.skip(ftype); 237 | break; 238 | default: 239 | input.skip(ftype); 240 | } 241 | input.readFieldEnd(); 242 | } 243 | input.readStructEnd(); 244 | return; 245 | }; 246 | 247 | Extension_call_result.prototype.write = function(output) { 248 | output.writeStructBegin('Extension_call_result'); 249 | if (this.success !== null && this.success !== undefined) { 250 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 251 | this.success.write(output); 252 | output.writeFieldEnd(); 253 | } 254 | output.writeFieldStop(); 255 | output.writeStructEnd(); 256 | return; 257 | }; 258 | 259 | ExtensionClient = exports.Client = function(output, pClass) { 260 | this.output = output; 261 | this.pClass = pClass; 262 | this._seqid = 0; 263 | this._reqs = {}; 264 | }; 265 | ExtensionClient.prototype = {}; 266 | ExtensionClient.prototype.seqid = function() { return this._seqid; } 267 | ExtensionClient.prototype.new_seqid = function() { return this._seqid += 1; } 268 | ExtensionClient.prototype.ping = function(callback) { 269 | this._seqid = this.new_seqid(); 270 | if (callback === undefined) { 271 | var _defer = Q.defer(); 272 | this._reqs[this.seqid()] = function(error, result) { 273 | if (error) { 274 | _defer.reject(error); 275 | } else { 276 | _defer.resolve(result); 277 | } 278 | }; 279 | this.send_ping(); 280 | return _defer.promise; 281 | } else { 282 | this._reqs[this.seqid()] = callback; 283 | this.send_ping(); 284 | } 285 | }; 286 | 287 | ExtensionClient.prototype.send_ping = function() { 288 | var output = new this.pClass(this.output); 289 | output.writeMessageBegin('ping', Thrift.MessageType.CALL, this.seqid()); 290 | var args = new Extension_ping_args(); 291 | args.write(output); 292 | output.writeMessageEnd(); 293 | return this.output.flush(); 294 | }; 295 | 296 | ExtensionClient.prototype.recv_ping = function(input,mtype,rseqid) { 297 | var callback = this._reqs[rseqid] || function() {}; 298 | delete this._reqs[rseqid]; 299 | if (mtype == Thrift.MessageType.EXCEPTION) { 300 | var x = new Thrift.TApplicationException(); 301 | x.read(input); 302 | input.readMessageEnd(); 303 | return callback(x); 304 | } 305 | var result = new Extension_ping_result(); 306 | result.read(input); 307 | input.readMessageEnd(); 308 | 309 | if (null !== result.success) { 310 | return callback(null, result.success); 311 | } 312 | return callback('ping failed: unknown result'); 313 | }; 314 | ExtensionClient.prototype.call = function(registry, item, request, callback) { 315 | this._seqid = this.new_seqid(); 316 | if (callback === undefined) { 317 | var _defer = Q.defer(); 318 | this._reqs[this.seqid()] = function(error, result) { 319 | if (error) { 320 | _defer.reject(error); 321 | } else { 322 | _defer.resolve(result); 323 | } 324 | }; 325 | this.send_call(registry, item, request); 326 | return _defer.promise; 327 | } else { 328 | this._reqs[this.seqid()] = callback; 329 | this.send_call(registry, item, request); 330 | } 331 | }; 332 | 333 | ExtensionClient.prototype.send_call = function(registry, item, request) { 334 | var output = new this.pClass(this.output); 335 | output.writeMessageBegin('call', Thrift.MessageType.CALL, this.seqid()); 336 | var args = new Extension_call_args(); 337 | args.registry = registry; 338 | args.item = item; 339 | args.request = request; 340 | args.write(output); 341 | output.writeMessageEnd(); 342 | return this.output.flush(); 343 | }; 344 | 345 | ExtensionClient.prototype.recv_call = function(input,mtype,rseqid) { 346 | var callback = this._reqs[rseqid] || function() {}; 347 | delete this._reqs[rseqid]; 348 | if (mtype == Thrift.MessageType.EXCEPTION) { 349 | var x = new Thrift.TApplicationException(); 350 | x.read(input); 351 | input.readMessageEnd(); 352 | return callback(x); 353 | } 354 | var result = new Extension_call_result(); 355 | result.read(input); 356 | input.readMessageEnd(); 357 | 358 | if (null !== result.success) { 359 | return callback(null, result.success); 360 | } 361 | return callback('call failed: unknown result'); 362 | }; 363 | ExtensionProcessor = exports.Processor = function(handler) { 364 | this._handler = handler 365 | } 366 | ExtensionProcessor.prototype.process = function(input, output) { 367 | var r = input.readMessageBegin(); 368 | if (this['process_' + r.fname]) { 369 | return this['process_' + r.fname].call(this, r.rseqid, input, output); 370 | } else { 371 | input.skip(Thrift.Type.STRUCT); 372 | input.readMessageEnd(); 373 | var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname); 374 | output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid); 375 | x.write(output); 376 | output.writeMessageEnd(); 377 | output.flush(); 378 | } 379 | } 380 | 381 | ExtensionProcessor.prototype.process_ping = function(seqid, input, output) { 382 | var args = new Extension_ping_args(); 383 | args.read(input); 384 | input.readMessageEnd(); 385 | if (this._handler.ping.length === 0) { 386 | Q.fcall(this._handler.ping) 387 | .then(function(result) { 388 | var result = new Extension_ping_result({success: result}); 389 | output.writeMessageBegin("ping", Thrift.MessageType.REPLY, seqid); 390 | result.write(output); 391 | output.writeMessageEnd(); 392 | output.flush(); 393 | }, function (err) { 394 | var result = new Extension_ping_result(err); 395 | output.writeMessageBegin("ping", Thrift.MessageType.REPLY, seqid); 396 | result.write(output); 397 | output.writeMessageEnd(); 398 | output.flush(); 399 | }); 400 | } else { 401 | this._handler.ping( function (err, result) { 402 | var result = new Extension_ping_result((err != null ? err : {success: result})); 403 | output.writeMessageBegin("ping", Thrift.MessageType.REPLY, seqid); 404 | result.write(output); 405 | output.writeMessageEnd(); 406 | output.flush(); 407 | }); 408 | } 409 | } 410 | 411 | ExtensionProcessor.prototype.process_call = function(seqid, input, output) { 412 | var args = new Extension_call_args(); 413 | args.read(input); 414 | input.readMessageEnd(); 415 | if (this._handler.call.length === 3) { 416 | Q.fcall(this._handler.call, args.registry, args.item, args.request) 417 | .then(function(result) { 418 | var result = new Extension_call_result({success: result}); 419 | output.writeMessageBegin("call", Thrift.MessageType.REPLY, seqid); 420 | result.write(output); 421 | output.writeMessageEnd(); 422 | output.flush(); 423 | }, function (err) { 424 | var result = new Extension_call_result(err); 425 | output.writeMessageBegin("call", Thrift.MessageType.REPLY, seqid); 426 | result.write(output); 427 | output.writeMessageEnd(); 428 | output.flush(); 429 | }); 430 | } else { 431 | this._handler.call(args.registry, args.item, args.request, function (err, result) { 432 | var result = new Extension_call_result((err != null ? err : {success: result})); 433 | output.writeMessageBegin("call", Thrift.MessageType.REPLY, seqid); 434 | result.write(output); 435 | output.writeMessageEnd(); 436 | output.flush(); 437 | }); 438 | } 439 | } 440 | 441 | -------------------------------------------------------------------------------- /gen-nodejs/osquery_types.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift Compiler (0.9.2) 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var thrift = require('thrift'); 7 | var Thrift = thrift.Thrift; 8 | var Q = thrift.Q; 9 | 10 | 11 | var ttypes = module.exports = {}; 12 | ttypes.ExtensionCode = { 13 | 'EXT_SUCCESS' : 0, 14 | 'EXT_FAILED' : 1, 15 | 'EXT_FATAL' : 2 16 | }; 17 | InternalOptionInfo = module.exports.InternalOptionInfo = function(args) { 18 | this.value = null; 19 | this.default_value = null; 20 | this.type = null; 21 | if (args) { 22 | if (args.value !== undefined) { 23 | this.value = args.value; 24 | } 25 | if (args.default_value !== undefined) { 26 | this.default_value = args.default_value; 27 | } 28 | if (args.type !== undefined) { 29 | this.type = args.type; 30 | } 31 | } 32 | }; 33 | InternalOptionInfo.prototype = {}; 34 | InternalOptionInfo.prototype.read = function(input) { 35 | input.readStructBegin(); 36 | while (true) 37 | { 38 | var ret = input.readFieldBegin(); 39 | var fname = ret.fname; 40 | var ftype = ret.ftype; 41 | var fid = ret.fid; 42 | if (ftype == Thrift.Type.STOP) { 43 | break; 44 | } 45 | switch (fid) 46 | { 47 | case 1: 48 | if (ftype == Thrift.Type.STRING) { 49 | this.value = input.readString(); 50 | } else { 51 | input.skip(ftype); 52 | } 53 | break; 54 | case 2: 55 | if (ftype == Thrift.Type.STRING) { 56 | this.default_value = input.readString(); 57 | } else { 58 | input.skip(ftype); 59 | } 60 | break; 61 | case 3: 62 | if (ftype == Thrift.Type.STRING) { 63 | this.type = input.readString(); 64 | } else { 65 | input.skip(ftype); 66 | } 67 | break; 68 | default: 69 | input.skip(ftype); 70 | } 71 | input.readFieldEnd(); 72 | } 73 | input.readStructEnd(); 74 | return; 75 | }; 76 | 77 | InternalOptionInfo.prototype.write = function(output) { 78 | output.writeStructBegin('InternalOptionInfo'); 79 | if (this.value !== null && this.value !== undefined) { 80 | output.writeFieldBegin('value', Thrift.Type.STRING, 1); 81 | output.writeString(this.value); 82 | output.writeFieldEnd(); 83 | } 84 | if (this.default_value !== null && this.default_value !== undefined) { 85 | output.writeFieldBegin('default_value', Thrift.Type.STRING, 2); 86 | output.writeString(this.default_value); 87 | output.writeFieldEnd(); 88 | } 89 | if (this.type !== null && this.type !== undefined) { 90 | output.writeFieldBegin('type', Thrift.Type.STRING, 3); 91 | output.writeString(this.type); 92 | output.writeFieldEnd(); 93 | } 94 | output.writeFieldStop(); 95 | output.writeStructEnd(); 96 | return; 97 | }; 98 | 99 | InternalExtensionInfo = module.exports.InternalExtensionInfo = function(args) { 100 | this.name = null; 101 | this.version = null; 102 | this.sdk_version = null; 103 | this.min_sdk_version = null; 104 | if (args) { 105 | if (args.name !== undefined) { 106 | this.name = args.name; 107 | } 108 | if (args.version !== undefined) { 109 | this.version = args.version; 110 | } 111 | if (args.sdk_version !== undefined) { 112 | this.sdk_version = args.sdk_version; 113 | } 114 | if (args.min_sdk_version !== undefined) { 115 | this.min_sdk_version = args.min_sdk_version; 116 | } 117 | } 118 | }; 119 | InternalExtensionInfo.prototype = {}; 120 | InternalExtensionInfo.prototype.read = function(input) { 121 | input.readStructBegin(); 122 | while (true) 123 | { 124 | var ret = input.readFieldBegin(); 125 | var fname = ret.fname; 126 | var ftype = ret.ftype; 127 | var fid = ret.fid; 128 | if (ftype == Thrift.Type.STOP) { 129 | break; 130 | } 131 | switch (fid) 132 | { 133 | case 1: 134 | if (ftype == Thrift.Type.STRING) { 135 | this.name = input.readString(); 136 | } else { 137 | input.skip(ftype); 138 | } 139 | break; 140 | case 2: 141 | if (ftype == Thrift.Type.STRING) { 142 | this.version = input.readString(); 143 | } else { 144 | input.skip(ftype); 145 | } 146 | break; 147 | case 3: 148 | if (ftype == Thrift.Type.STRING) { 149 | this.sdk_version = input.readString(); 150 | } else { 151 | input.skip(ftype); 152 | } 153 | break; 154 | case 4: 155 | if (ftype == Thrift.Type.STRING) { 156 | this.min_sdk_version = input.readString(); 157 | } else { 158 | input.skip(ftype); 159 | } 160 | break; 161 | default: 162 | input.skip(ftype); 163 | } 164 | input.readFieldEnd(); 165 | } 166 | input.readStructEnd(); 167 | return; 168 | }; 169 | 170 | InternalExtensionInfo.prototype.write = function(output) { 171 | output.writeStructBegin('InternalExtensionInfo'); 172 | if (this.name !== null && this.name !== undefined) { 173 | output.writeFieldBegin('name', Thrift.Type.STRING, 1); 174 | output.writeString(this.name); 175 | output.writeFieldEnd(); 176 | } 177 | if (this.version !== null && this.version !== undefined) { 178 | output.writeFieldBegin('version', Thrift.Type.STRING, 2); 179 | output.writeString(this.version); 180 | output.writeFieldEnd(); 181 | } 182 | if (this.sdk_version !== null && this.sdk_version !== undefined) { 183 | output.writeFieldBegin('sdk_version', Thrift.Type.STRING, 3); 184 | output.writeString(this.sdk_version); 185 | output.writeFieldEnd(); 186 | } 187 | if (this.min_sdk_version !== null && this.min_sdk_version !== undefined) { 188 | output.writeFieldBegin('min_sdk_version', Thrift.Type.STRING, 4); 189 | output.writeString(this.min_sdk_version); 190 | output.writeFieldEnd(); 191 | } 192 | output.writeFieldStop(); 193 | output.writeStructEnd(); 194 | return; 195 | }; 196 | 197 | ExtensionStatus = module.exports.ExtensionStatus = function(args) { 198 | this.code = null; 199 | this.message = null; 200 | this.uuid = null; 201 | if (args) { 202 | if (args.code !== undefined) { 203 | this.code = args.code; 204 | } 205 | if (args.message !== undefined) { 206 | this.message = args.message; 207 | } 208 | if (args.uuid !== undefined) { 209 | this.uuid = args.uuid; 210 | } 211 | } 212 | }; 213 | ExtensionStatus.prototype = {}; 214 | ExtensionStatus.prototype.read = function(input) { 215 | input.readStructBegin(); 216 | while (true) 217 | { 218 | var ret = input.readFieldBegin(); 219 | var fname = ret.fname; 220 | var ftype = ret.ftype; 221 | var fid = ret.fid; 222 | if (ftype == Thrift.Type.STOP) { 223 | break; 224 | } 225 | switch (fid) 226 | { 227 | case 1: 228 | if (ftype == Thrift.Type.I32) { 229 | this.code = input.readI32(); 230 | } else { 231 | input.skip(ftype); 232 | } 233 | break; 234 | case 2: 235 | if (ftype == Thrift.Type.STRING) { 236 | this.message = input.readString(); 237 | } else { 238 | input.skip(ftype); 239 | } 240 | break; 241 | case 3: 242 | if (ftype == Thrift.Type.I64) { 243 | this.uuid = input.readI64(); 244 | } else { 245 | input.skip(ftype); 246 | } 247 | break; 248 | default: 249 | input.skip(ftype); 250 | } 251 | input.readFieldEnd(); 252 | } 253 | input.readStructEnd(); 254 | return; 255 | }; 256 | 257 | ExtensionStatus.prototype.write = function(output) { 258 | output.writeStructBegin('ExtensionStatus'); 259 | if (this.code !== null && this.code !== undefined) { 260 | output.writeFieldBegin('code', Thrift.Type.I32, 1); 261 | output.writeI32(this.code); 262 | output.writeFieldEnd(); 263 | } 264 | if (this.message !== null && this.message !== undefined) { 265 | output.writeFieldBegin('message', Thrift.Type.STRING, 2); 266 | output.writeString(this.message); 267 | output.writeFieldEnd(); 268 | } 269 | if (this.uuid !== null && this.uuid !== undefined) { 270 | output.writeFieldBegin('uuid', Thrift.Type.I64, 3); 271 | output.writeI64(this.uuid); 272 | output.writeFieldEnd(); 273 | } 274 | output.writeFieldStop(); 275 | output.writeStructEnd(); 276 | return; 277 | }; 278 | 279 | ExtensionResponse = module.exports.ExtensionResponse = function(args) { 280 | this.status = null; 281 | this.response = null; 282 | if (args) { 283 | if (args.status !== undefined) { 284 | this.status = args.status; 285 | } 286 | if (args.response !== undefined) { 287 | this.response = args.response; 288 | } 289 | } 290 | }; 291 | ExtensionResponse.prototype = {}; 292 | ExtensionResponse.prototype.read = function(input) { 293 | input.readStructBegin(); 294 | while (true) 295 | { 296 | var ret = input.readFieldBegin(); 297 | var fname = ret.fname; 298 | var ftype = ret.ftype; 299 | var fid = ret.fid; 300 | if (ftype == Thrift.Type.STOP) { 301 | break; 302 | } 303 | switch (fid) 304 | { 305 | case 1: 306 | if (ftype == Thrift.Type.STRUCT) { 307 | this.status = new ttypes.ExtensionStatus(); 308 | this.status.read(input); 309 | } else { 310 | input.skip(ftype); 311 | } 312 | break; 313 | case 2: 314 | if (ftype == Thrift.Type.LIST) { 315 | var _size0 = 0; 316 | var _rtmp34; 317 | this.response = []; 318 | var _etype3 = 0; 319 | _rtmp34 = input.readListBegin(); 320 | _etype3 = _rtmp34.etype; 321 | _size0 = _rtmp34.size; 322 | for (var _i5 = 0; _i5 < _size0; ++_i5) 323 | { 324 | var elem6 = null; 325 | var _size7 = 0; 326 | var _rtmp311; 327 | elem6 = {}; 328 | var _ktype8 = 0; 329 | var _vtype9 = 0; 330 | _rtmp311 = input.readMapBegin(); 331 | _ktype8 = _rtmp311.ktype; 332 | _vtype9 = _rtmp311.vtype; 333 | _size7 = _rtmp311.size; 334 | for (var _i12 = 0; _i12 < _size7; ++_i12) 335 | { 336 | var key13 = null; 337 | var val14 = null; 338 | key13 = input.readString(); 339 | val14 = input.readString(); 340 | elem6[key13] = val14; 341 | } 342 | input.readMapEnd(); 343 | this.response.push(elem6); 344 | } 345 | input.readListEnd(); 346 | } else { 347 | input.skip(ftype); 348 | } 349 | break; 350 | default: 351 | input.skip(ftype); 352 | } 353 | input.readFieldEnd(); 354 | } 355 | input.readStructEnd(); 356 | return; 357 | }; 358 | 359 | ExtensionResponse.prototype.write = function(output) { 360 | output.writeStructBegin('ExtensionResponse'); 361 | if (this.status !== null && this.status !== undefined) { 362 | output.writeFieldBegin('status', Thrift.Type.STRUCT, 1); 363 | this.status.write(output); 364 | output.writeFieldEnd(); 365 | } 366 | if (this.response !== null && this.response !== undefined) { 367 | output.writeFieldBegin('response', Thrift.Type.LIST, 2); 368 | output.writeListBegin(Thrift.Type.MAP, this.response.length); 369 | for (var iter15 in this.response) 370 | { 371 | if (this.response.hasOwnProperty(iter15)) 372 | { 373 | iter15 = this.response[iter15]; 374 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.STRING, Thrift.objectLength(iter15)); 375 | for (var kiter16 in iter15) 376 | { 377 | if (iter15.hasOwnProperty(kiter16)) 378 | { 379 | var viter17 = iter15[kiter16]; 380 | output.writeString(kiter16); 381 | output.writeString(viter17); 382 | } 383 | } 384 | output.writeMapEnd(); 385 | } 386 | } 387 | output.writeListEnd(); 388 | output.writeFieldEnd(); 389 | } 390 | output.writeFieldStop(); 391 | output.writeStructEnd(); 392 | return; 393 | }; 394 | 395 | ExtensionException = module.exports.ExtensionException = function(args) { 396 | Thrift.TException.call(this, "ExtensionException") 397 | this.name = "ExtensionException" 398 | this.code = null; 399 | this.message = null; 400 | this.uuid = null; 401 | if (args) { 402 | if (args.code !== undefined) { 403 | this.code = args.code; 404 | } 405 | if (args.message !== undefined) { 406 | this.message = args.message; 407 | } 408 | if (args.uuid !== undefined) { 409 | this.uuid = args.uuid; 410 | } 411 | } 412 | }; 413 | Thrift.inherits(ExtensionException, Thrift.TException); 414 | ExtensionException.prototype.name = 'ExtensionException'; 415 | ExtensionException.prototype.read = function(input) { 416 | input.readStructBegin(); 417 | while (true) 418 | { 419 | var ret = input.readFieldBegin(); 420 | var fname = ret.fname; 421 | var ftype = ret.ftype; 422 | var fid = ret.fid; 423 | if (ftype == Thrift.Type.STOP) { 424 | break; 425 | } 426 | switch (fid) 427 | { 428 | case 1: 429 | if (ftype == Thrift.Type.I32) { 430 | this.code = input.readI32(); 431 | } else { 432 | input.skip(ftype); 433 | } 434 | break; 435 | case 2: 436 | if (ftype == Thrift.Type.STRING) { 437 | this.message = input.readString(); 438 | } else { 439 | input.skip(ftype); 440 | } 441 | break; 442 | case 3: 443 | if (ftype == Thrift.Type.I64) { 444 | this.uuid = input.readI64(); 445 | } else { 446 | input.skip(ftype); 447 | } 448 | break; 449 | default: 450 | input.skip(ftype); 451 | } 452 | input.readFieldEnd(); 453 | } 454 | input.readStructEnd(); 455 | return; 456 | }; 457 | 458 | ExtensionException.prototype.write = function(output) { 459 | output.writeStructBegin('ExtensionException'); 460 | if (this.code !== null && this.code !== undefined) { 461 | output.writeFieldBegin('code', Thrift.Type.I32, 1); 462 | output.writeI32(this.code); 463 | output.writeFieldEnd(); 464 | } 465 | if (this.message !== null && this.message !== undefined) { 466 | output.writeFieldBegin('message', Thrift.Type.STRING, 2); 467 | output.writeString(this.message); 468 | output.writeFieldEnd(); 469 | } 470 | if (this.uuid !== null && this.uuid !== undefined) { 471 | output.writeFieldBegin('uuid', Thrift.Type.I64, 3); 472 | output.writeI64(this.uuid); 473 | output.writeFieldEnd(); 474 | } 475 | output.writeFieldStop(); 476 | output.writeStructEnd(); 477 | return; 478 | }; 479 | 480 | -------------------------------------------------------------------------------- /gen-nodejs/ExtensionManager.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift Compiler (0.9.2) 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | var thrift = require('thrift'); 7 | var Thrift = thrift.Thrift; 8 | var Q = thrift.Q; 9 | 10 | 11 | var Extension = require('./Extension') 12 | var ExtensionClient = Extension.Client 13 | var ExtensionProcessor = Extension.Processor 14 | var ttypes = require('./osquery_types'); 15 | //HELPER FUNCTIONS AND STRUCTURES 16 | 17 | ExtensionManager_extensions_args = function(args) { 18 | }; 19 | ExtensionManager_extensions_args.prototype = {}; 20 | ExtensionManager_extensions_args.prototype.read = function(input) { 21 | input.readStructBegin(); 22 | while (true) 23 | { 24 | var ret = input.readFieldBegin(); 25 | var fname = ret.fname; 26 | var ftype = ret.ftype; 27 | var fid = ret.fid; 28 | if (ftype == Thrift.Type.STOP) { 29 | break; 30 | } 31 | input.skip(ftype); 32 | input.readFieldEnd(); 33 | } 34 | input.readStructEnd(); 35 | return; 36 | }; 37 | 38 | ExtensionManager_extensions_args.prototype.write = function(output) { 39 | output.writeStructBegin('ExtensionManager_extensions_args'); 40 | output.writeFieldStop(); 41 | output.writeStructEnd(); 42 | return; 43 | }; 44 | 45 | ExtensionManager_extensions_result = function(args) { 46 | this.success = null; 47 | if (args) { 48 | if (args.success !== undefined) { 49 | this.success = args.success; 50 | } 51 | } 52 | }; 53 | ExtensionManager_extensions_result.prototype = {}; 54 | ExtensionManager_extensions_result.prototype.read = function(input) { 55 | input.readStructBegin(); 56 | while (true) 57 | { 58 | var ret = input.readFieldBegin(); 59 | var fname = ret.fname; 60 | var ftype = ret.ftype; 61 | var fid = ret.fid; 62 | if (ftype == Thrift.Type.STOP) { 63 | break; 64 | } 65 | switch (fid) 66 | { 67 | case 0: 68 | if (ftype == Thrift.Type.MAP) { 69 | var _size28 = 0; 70 | var _rtmp332; 71 | this.success = {}; 72 | var _ktype29 = 0; 73 | var _vtype30 = 0; 74 | _rtmp332 = input.readMapBegin(); 75 | _ktype29 = _rtmp332.ktype; 76 | _vtype30 = _rtmp332.vtype; 77 | _size28 = _rtmp332.size; 78 | for (var _i33 = 0; _i33 < _size28; ++_i33) 79 | { 80 | var key34 = null; 81 | var val35 = null; 82 | key34 = input.readI64(); 83 | val35 = new ttypes.InternalExtensionInfo(); 84 | val35.read(input); 85 | this.success[key34] = val35; 86 | } 87 | input.readMapEnd(); 88 | } else { 89 | input.skip(ftype); 90 | } 91 | break; 92 | case 0: 93 | input.skip(ftype); 94 | break; 95 | default: 96 | input.skip(ftype); 97 | } 98 | input.readFieldEnd(); 99 | } 100 | input.readStructEnd(); 101 | return; 102 | }; 103 | 104 | ExtensionManager_extensions_result.prototype.write = function(output) { 105 | output.writeStructBegin('ExtensionManager_extensions_result'); 106 | if (this.success !== null && this.success !== undefined) { 107 | output.writeFieldBegin('success', Thrift.Type.MAP, 0); 108 | output.writeMapBegin(Thrift.Type.I64, Thrift.Type.STRUCT, Thrift.objectLength(this.success)); 109 | for (var kiter36 in this.success) 110 | { 111 | if (this.success.hasOwnProperty(kiter36)) 112 | { 113 | var viter37 = this.success[kiter36]; 114 | output.writeI64(kiter36); 115 | viter37.write(output); 116 | } 117 | } 118 | output.writeMapEnd(); 119 | output.writeFieldEnd(); 120 | } 121 | output.writeFieldStop(); 122 | output.writeStructEnd(); 123 | return; 124 | }; 125 | 126 | ExtensionManager_options_args = function(args) { 127 | }; 128 | ExtensionManager_options_args.prototype = {}; 129 | ExtensionManager_options_args.prototype.read = function(input) { 130 | input.readStructBegin(); 131 | while (true) 132 | { 133 | var ret = input.readFieldBegin(); 134 | var fname = ret.fname; 135 | var ftype = ret.ftype; 136 | var fid = ret.fid; 137 | if (ftype == Thrift.Type.STOP) { 138 | break; 139 | } 140 | input.skip(ftype); 141 | input.readFieldEnd(); 142 | } 143 | input.readStructEnd(); 144 | return; 145 | }; 146 | 147 | ExtensionManager_options_args.prototype.write = function(output) { 148 | output.writeStructBegin('ExtensionManager_options_args'); 149 | output.writeFieldStop(); 150 | output.writeStructEnd(); 151 | return; 152 | }; 153 | 154 | ExtensionManager_options_result = function(args) { 155 | this.success = null; 156 | if (args) { 157 | if (args.success !== undefined) { 158 | this.success = args.success; 159 | } 160 | } 161 | }; 162 | ExtensionManager_options_result.prototype = {}; 163 | ExtensionManager_options_result.prototype.read = function(input) { 164 | input.readStructBegin(); 165 | while (true) 166 | { 167 | var ret = input.readFieldBegin(); 168 | var fname = ret.fname; 169 | var ftype = ret.ftype; 170 | var fid = ret.fid; 171 | if (ftype == Thrift.Type.STOP) { 172 | break; 173 | } 174 | switch (fid) 175 | { 176 | case 0: 177 | if (ftype == Thrift.Type.MAP) { 178 | var _size38 = 0; 179 | var _rtmp342; 180 | this.success = {}; 181 | var _ktype39 = 0; 182 | var _vtype40 = 0; 183 | _rtmp342 = input.readMapBegin(); 184 | _ktype39 = _rtmp342.ktype; 185 | _vtype40 = _rtmp342.vtype; 186 | _size38 = _rtmp342.size; 187 | for (var _i43 = 0; _i43 < _size38; ++_i43) 188 | { 189 | var key44 = null; 190 | var val45 = null; 191 | key44 = input.readString(); 192 | val45 = new ttypes.InternalOptionInfo(); 193 | val45.read(input); 194 | this.success[key44] = val45; 195 | } 196 | input.readMapEnd(); 197 | } else { 198 | input.skip(ftype); 199 | } 200 | break; 201 | case 0: 202 | input.skip(ftype); 203 | break; 204 | default: 205 | input.skip(ftype); 206 | } 207 | input.readFieldEnd(); 208 | } 209 | input.readStructEnd(); 210 | return; 211 | }; 212 | 213 | ExtensionManager_options_result.prototype.write = function(output) { 214 | output.writeStructBegin('ExtensionManager_options_result'); 215 | if (this.success !== null && this.success !== undefined) { 216 | output.writeFieldBegin('success', Thrift.Type.MAP, 0); 217 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.STRUCT, Thrift.objectLength(this.success)); 218 | for (var kiter46 in this.success) 219 | { 220 | if (this.success.hasOwnProperty(kiter46)) 221 | { 222 | var viter47 = this.success[kiter46]; 223 | output.writeString(kiter46); 224 | viter47.write(output); 225 | } 226 | } 227 | output.writeMapEnd(); 228 | output.writeFieldEnd(); 229 | } 230 | output.writeFieldStop(); 231 | output.writeStructEnd(); 232 | return; 233 | }; 234 | 235 | ExtensionManager_registerExtension_args = function(args) { 236 | this.info = null; 237 | this.registry = null; 238 | if (args) { 239 | if (args.info !== undefined) { 240 | this.info = args.info; 241 | } 242 | if (args.registry !== undefined) { 243 | this.registry = args.registry; 244 | } 245 | } 246 | }; 247 | ExtensionManager_registerExtension_args.prototype = {}; 248 | ExtensionManager_registerExtension_args.prototype.read = function(input) { 249 | input.readStructBegin(); 250 | while (true) 251 | { 252 | var ret = input.readFieldBegin(); 253 | var fname = ret.fname; 254 | var ftype = ret.ftype; 255 | var fid = ret.fid; 256 | if (ftype == Thrift.Type.STOP) { 257 | break; 258 | } 259 | switch (fid) 260 | { 261 | case 1: 262 | if (ftype == Thrift.Type.STRUCT) { 263 | this.info = new ttypes.InternalExtensionInfo(); 264 | this.info.read(input); 265 | } else { 266 | input.skip(ftype); 267 | } 268 | break; 269 | case 2: 270 | if (ftype == Thrift.Type.MAP) { 271 | var _size48 = 0; 272 | var _rtmp352; 273 | this.registry = {}; 274 | var _ktype49 = 0; 275 | var _vtype50 = 0; 276 | _rtmp352 = input.readMapBegin(); 277 | _ktype49 = _rtmp352.ktype; 278 | _vtype50 = _rtmp352.vtype; 279 | _size48 = _rtmp352.size; 280 | for (var _i53 = 0; _i53 < _size48; ++_i53) 281 | { 282 | var key54 = null; 283 | var val55 = null; 284 | key54 = input.readString(); 285 | var _size56 = 0; 286 | var _rtmp360; 287 | val55 = {}; 288 | var _ktype57 = 0; 289 | var _vtype58 = 0; 290 | _rtmp360 = input.readMapBegin(); 291 | _ktype57 = _rtmp360.ktype; 292 | _vtype58 = _rtmp360.vtype; 293 | _size56 = _rtmp360.size; 294 | for (var _i61 = 0; _i61 < _size56; ++_i61) 295 | { 296 | var key62 = null; 297 | var val63 = null; 298 | key62 = input.readString(); 299 | var _size64 = 0; 300 | var _rtmp368; 301 | val63 = []; 302 | var _etype67 = 0; 303 | _rtmp368 = input.readListBegin(); 304 | _etype67 = _rtmp368.etype; 305 | _size64 = _rtmp368.size; 306 | for (var _i69 = 0; _i69 < _size64; ++_i69) 307 | { 308 | var elem70 = null; 309 | var _size71 = 0; 310 | var _rtmp375; 311 | elem70 = {}; 312 | var _ktype72 = 0; 313 | var _vtype73 = 0; 314 | _rtmp375 = input.readMapBegin(); 315 | _ktype72 = _rtmp375.ktype; 316 | _vtype73 = _rtmp375.vtype; 317 | _size71 = _rtmp375.size; 318 | for (var _i76 = 0; _i76 < _size71; ++_i76) 319 | { 320 | var key77 = null; 321 | var val78 = null; 322 | key77 = input.readString(); 323 | val78 = input.readString(); 324 | elem70[key77] = val78; 325 | } 326 | input.readMapEnd(); 327 | val63.push(elem70); 328 | } 329 | input.readListEnd(); 330 | val55[key62] = val63; 331 | } 332 | input.readMapEnd(); 333 | this.registry[key54] = val55; 334 | } 335 | input.readMapEnd(); 336 | } else { 337 | input.skip(ftype); 338 | } 339 | break; 340 | default: 341 | input.skip(ftype); 342 | } 343 | input.readFieldEnd(); 344 | } 345 | input.readStructEnd(); 346 | return; 347 | }; 348 | 349 | ExtensionManager_registerExtension_args.prototype.write = function(output) { 350 | output.writeStructBegin('ExtensionManager_registerExtension_args'); 351 | if (this.info !== null && this.info !== undefined) { 352 | output.writeFieldBegin('info', Thrift.Type.STRUCT, 1); 353 | this.info.write(output); 354 | output.writeFieldEnd(); 355 | } 356 | if (this.registry !== null && this.registry !== undefined) { 357 | output.writeFieldBegin('registry', Thrift.Type.MAP, 2); 358 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.MAP, Thrift.objectLength(this.registry)); 359 | for (var kiter79 in this.registry) 360 | { 361 | if (this.registry.hasOwnProperty(kiter79)) 362 | { 363 | var viter80 = this.registry[kiter79]; 364 | output.writeString(kiter79); 365 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.LIST, Thrift.objectLength(viter80)); 366 | for (var kiter81 in viter80) 367 | { 368 | if (viter80.hasOwnProperty(kiter81)) 369 | { 370 | var viter82 = viter80[kiter81]; 371 | output.writeString(kiter81); 372 | output.writeListBegin(Thrift.Type.MAP, viter82.length); 373 | for (var iter83 in viter82) 374 | { 375 | if (viter82.hasOwnProperty(iter83)) 376 | { 377 | iter83 = viter82[iter83]; 378 | output.writeMapBegin(Thrift.Type.STRING, Thrift.Type.STRING, Thrift.objectLength(iter83)); 379 | for (var kiter84 in iter83) 380 | { 381 | if (iter83.hasOwnProperty(kiter84)) 382 | { 383 | var viter85 = iter83[kiter84]; 384 | output.writeString(kiter84); 385 | output.writeString(viter85); 386 | } 387 | } 388 | output.writeMapEnd(); 389 | } 390 | } 391 | output.writeListEnd(); 392 | } 393 | } 394 | output.writeMapEnd(); 395 | } 396 | } 397 | output.writeMapEnd(); 398 | output.writeFieldEnd(); 399 | } 400 | output.writeFieldStop(); 401 | output.writeStructEnd(); 402 | return; 403 | }; 404 | 405 | ExtensionManager_registerExtension_result = function(args) { 406 | this.success = null; 407 | if (args) { 408 | if (args.success !== undefined) { 409 | this.success = args.success; 410 | } 411 | } 412 | }; 413 | ExtensionManager_registerExtension_result.prototype = {}; 414 | ExtensionManager_registerExtension_result.prototype.read = function(input) { 415 | input.readStructBegin(); 416 | while (true) 417 | { 418 | var ret = input.readFieldBegin(); 419 | var fname = ret.fname; 420 | var ftype = ret.ftype; 421 | var fid = ret.fid; 422 | if (ftype == Thrift.Type.STOP) { 423 | break; 424 | } 425 | switch (fid) 426 | { 427 | case 0: 428 | if (ftype == Thrift.Type.STRUCT) { 429 | this.success = new ttypes.ExtensionStatus(); 430 | this.success.read(input); 431 | } else { 432 | input.skip(ftype); 433 | } 434 | break; 435 | case 0: 436 | input.skip(ftype); 437 | break; 438 | default: 439 | input.skip(ftype); 440 | } 441 | input.readFieldEnd(); 442 | } 443 | input.readStructEnd(); 444 | return; 445 | }; 446 | 447 | ExtensionManager_registerExtension_result.prototype.write = function(output) { 448 | output.writeStructBegin('ExtensionManager_registerExtension_result'); 449 | if (this.success !== null && this.success !== undefined) { 450 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 451 | this.success.write(output); 452 | output.writeFieldEnd(); 453 | } 454 | output.writeFieldStop(); 455 | output.writeStructEnd(); 456 | return; 457 | }; 458 | 459 | ExtensionManager_deregisterExtension_args = function(args) { 460 | this.uuid = null; 461 | if (args) { 462 | if (args.uuid !== undefined) { 463 | this.uuid = args.uuid; 464 | } 465 | } 466 | }; 467 | ExtensionManager_deregisterExtension_args.prototype = {}; 468 | ExtensionManager_deregisterExtension_args.prototype.read = function(input) { 469 | input.readStructBegin(); 470 | while (true) 471 | { 472 | var ret = input.readFieldBegin(); 473 | var fname = ret.fname; 474 | var ftype = ret.ftype; 475 | var fid = ret.fid; 476 | if (ftype == Thrift.Type.STOP) { 477 | break; 478 | } 479 | switch (fid) 480 | { 481 | case 1: 482 | if (ftype == Thrift.Type.I64) { 483 | this.uuid = input.readI64(); 484 | } else { 485 | input.skip(ftype); 486 | } 487 | break; 488 | case 0: 489 | input.skip(ftype); 490 | break; 491 | default: 492 | input.skip(ftype); 493 | } 494 | input.readFieldEnd(); 495 | } 496 | input.readStructEnd(); 497 | return; 498 | }; 499 | 500 | ExtensionManager_deregisterExtension_args.prototype.write = function(output) { 501 | output.writeStructBegin('ExtensionManager_deregisterExtension_args'); 502 | if (this.uuid !== null && this.uuid !== undefined) { 503 | output.writeFieldBegin('uuid', Thrift.Type.I64, 1); 504 | output.writeI64(this.uuid); 505 | output.writeFieldEnd(); 506 | } 507 | output.writeFieldStop(); 508 | output.writeStructEnd(); 509 | return; 510 | }; 511 | 512 | ExtensionManager_deregisterExtension_result = function(args) { 513 | this.success = null; 514 | if (args) { 515 | if (args.success !== undefined) { 516 | this.success = args.success; 517 | } 518 | } 519 | }; 520 | ExtensionManager_deregisterExtension_result.prototype = {}; 521 | ExtensionManager_deregisterExtension_result.prototype.read = function(input) { 522 | input.readStructBegin(); 523 | while (true) 524 | { 525 | var ret = input.readFieldBegin(); 526 | var fname = ret.fname; 527 | var ftype = ret.ftype; 528 | var fid = ret.fid; 529 | if (ftype == Thrift.Type.STOP) { 530 | break; 531 | } 532 | switch (fid) 533 | { 534 | case 0: 535 | if (ftype == Thrift.Type.STRUCT) { 536 | this.success = new ttypes.ExtensionStatus(); 537 | this.success.read(input); 538 | } else { 539 | input.skip(ftype); 540 | } 541 | break; 542 | case 0: 543 | input.skip(ftype); 544 | break; 545 | default: 546 | input.skip(ftype); 547 | } 548 | input.readFieldEnd(); 549 | } 550 | input.readStructEnd(); 551 | return; 552 | }; 553 | 554 | ExtensionManager_deregisterExtension_result.prototype.write = function(output) { 555 | output.writeStructBegin('ExtensionManager_deregisterExtension_result'); 556 | if (this.success !== null && this.success !== undefined) { 557 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 558 | this.success.write(output); 559 | output.writeFieldEnd(); 560 | } 561 | output.writeFieldStop(); 562 | output.writeStructEnd(); 563 | return; 564 | }; 565 | 566 | ExtensionManager_query_args = function(args) { 567 | this.sql = null; 568 | if (args) { 569 | if (args.sql !== undefined) { 570 | this.sql = args.sql; 571 | } 572 | } 573 | }; 574 | ExtensionManager_query_args.prototype = {}; 575 | ExtensionManager_query_args.prototype.read = function(input) { 576 | input.readStructBegin(); 577 | while (true) 578 | { 579 | var ret = input.readFieldBegin(); 580 | var fname = ret.fname; 581 | var ftype = ret.ftype; 582 | var fid = ret.fid; 583 | if (ftype == Thrift.Type.STOP) { 584 | break; 585 | } 586 | switch (fid) 587 | { 588 | case 1: 589 | if (ftype == Thrift.Type.STRING) { 590 | this.sql = input.readString(); 591 | } else { 592 | input.skip(ftype); 593 | } 594 | break; 595 | case 0: 596 | input.skip(ftype); 597 | break; 598 | default: 599 | input.skip(ftype); 600 | } 601 | input.readFieldEnd(); 602 | } 603 | input.readStructEnd(); 604 | return; 605 | }; 606 | 607 | ExtensionManager_query_args.prototype.write = function(output) { 608 | output.writeStructBegin('ExtensionManager_query_args'); 609 | if (this.sql !== null && this.sql !== undefined) { 610 | output.writeFieldBegin('sql', Thrift.Type.STRING, 1); 611 | output.writeString(this.sql); 612 | output.writeFieldEnd(); 613 | } 614 | output.writeFieldStop(); 615 | output.writeStructEnd(); 616 | return; 617 | }; 618 | 619 | ExtensionManager_query_result = function(args) { 620 | this.success = null; 621 | if (args) { 622 | if (args.success !== undefined) { 623 | this.success = args.success; 624 | } 625 | } 626 | }; 627 | ExtensionManager_query_result.prototype = {}; 628 | ExtensionManager_query_result.prototype.read = function(input) { 629 | input.readStructBegin(); 630 | while (true) 631 | { 632 | var ret = input.readFieldBegin(); 633 | var fname = ret.fname; 634 | var ftype = ret.ftype; 635 | var fid = ret.fid; 636 | if (ftype == Thrift.Type.STOP) { 637 | break; 638 | } 639 | switch (fid) 640 | { 641 | case 0: 642 | if (ftype == Thrift.Type.STRUCT) { 643 | this.success = new ttypes.ExtensionResponse(); 644 | this.success.read(input); 645 | } else { 646 | input.skip(ftype); 647 | } 648 | break; 649 | case 0: 650 | input.skip(ftype); 651 | break; 652 | default: 653 | input.skip(ftype); 654 | } 655 | input.readFieldEnd(); 656 | } 657 | input.readStructEnd(); 658 | return; 659 | }; 660 | 661 | ExtensionManager_query_result.prototype.write = function(output) { 662 | output.writeStructBegin('ExtensionManager_query_result'); 663 | if (this.success !== null && this.success !== undefined) { 664 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 665 | this.success.write(output); 666 | output.writeFieldEnd(); 667 | } 668 | output.writeFieldStop(); 669 | output.writeStructEnd(); 670 | return; 671 | }; 672 | 673 | ExtensionManager_getQueryColumns_args = function(args) { 674 | this.sql = null; 675 | if (args) { 676 | if (args.sql !== undefined) { 677 | this.sql = args.sql; 678 | } 679 | } 680 | }; 681 | ExtensionManager_getQueryColumns_args.prototype = {}; 682 | ExtensionManager_getQueryColumns_args.prototype.read = function(input) { 683 | input.readStructBegin(); 684 | while (true) 685 | { 686 | var ret = input.readFieldBegin(); 687 | var fname = ret.fname; 688 | var ftype = ret.ftype; 689 | var fid = ret.fid; 690 | if (ftype == Thrift.Type.STOP) { 691 | break; 692 | } 693 | switch (fid) 694 | { 695 | case 1: 696 | if (ftype == Thrift.Type.STRING) { 697 | this.sql = input.readString(); 698 | } else { 699 | input.skip(ftype); 700 | } 701 | break; 702 | case 0: 703 | input.skip(ftype); 704 | break; 705 | default: 706 | input.skip(ftype); 707 | } 708 | input.readFieldEnd(); 709 | } 710 | input.readStructEnd(); 711 | return; 712 | }; 713 | 714 | ExtensionManager_getQueryColumns_args.prototype.write = function(output) { 715 | output.writeStructBegin('ExtensionManager_getQueryColumns_args'); 716 | if (this.sql !== null && this.sql !== undefined) { 717 | output.writeFieldBegin('sql', Thrift.Type.STRING, 1); 718 | output.writeString(this.sql); 719 | output.writeFieldEnd(); 720 | } 721 | output.writeFieldStop(); 722 | output.writeStructEnd(); 723 | return; 724 | }; 725 | 726 | ExtensionManager_getQueryColumns_result = function(args) { 727 | this.success = null; 728 | if (args) { 729 | if (args.success !== undefined) { 730 | this.success = args.success; 731 | } 732 | } 733 | }; 734 | ExtensionManager_getQueryColumns_result.prototype = {}; 735 | ExtensionManager_getQueryColumns_result.prototype.read = function(input) { 736 | input.readStructBegin(); 737 | while (true) 738 | { 739 | var ret = input.readFieldBegin(); 740 | var fname = ret.fname; 741 | var ftype = ret.ftype; 742 | var fid = ret.fid; 743 | if (ftype == Thrift.Type.STOP) { 744 | break; 745 | } 746 | switch (fid) 747 | { 748 | case 0: 749 | if (ftype == Thrift.Type.STRUCT) { 750 | this.success = new ttypes.ExtensionResponse(); 751 | this.success.read(input); 752 | } else { 753 | input.skip(ftype); 754 | } 755 | break; 756 | case 0: 757 | input.skip(ftype); 758 | break; 759 | default: 760 | input.skip(ftype); 761 | } 762 | input.readFieldEnd(); 763 | } 764 | input.readStructEnd(); 765 | return; 766 | }; 767 | 768 | ExtensionManager_getQueryColumns_result.prototype.write = function(output) { 769 | output.writeStructBegin('ExtensionManager_getQueryColumns_result'); 770 | if (this.success !== null && this.success !== undefined) { 771 | output.writeFieldBegin('success', Thrift.Type.STRUCT, 0); 772 | this.success.write(output); 773 | output.writeFieldEnd(); 774 | } 775 | output.writeFieldStop(); 776 | output.writeStructEnd(); 777 | return; 778 | }; 779 | 780 | ExtensionManagerClient = exports.Client = function(output, pClass) { 781 | this.output = output; 782 | this.pClass = pClass; 783 | this._seqid = 0; 784 | this._reqs = {}; 785 | }; 786 | Thrift.inherits(ExtensionManagerClient, ExtensionClient); 787 | ExtensionManagerClient.prototype.seqid = function() { return this._seqid; } 788 | ExtensionManagerClient.prototype.new_seqid = function() { return this._seqid += 1; } 789 | ExtensionManagerClient.prototype.extensions = function(callback) { 790 | this._seqid = this.new_seqid(); 791 | if (callback === undefined) { 792 | var _defer = Q.defer(); 793 | this._reqs[this.seqid()] = function(error, result) { 794 | if (error) { 795 | _defer.reject(error); 796 | } else { 797 | _defer.resolve(result); 798 | } 799 | }; 800 | this.send_extensions(); 801 | return _defer.promise; 802 | } else { 803 | this._reqs[this.seqid()] = callback; 804 | this.send_extensions(); 805 | } 806 | }; 807 | 808 | ExtensionManagerClient.prototype.send_extensions = function() { 809 | var output = new this.pClass(this.output); 810 | output.writeMessageBegin('extensions', Thrift.MessageType.CALL, this.seqid()); 811 | var args = new ExtensionManager_extensions_args(); 812 | args.write(output); 813 | output.writeMessageEnd(); 814 | return this.output.flush(); 815 | }; 816 | 817 | ExtensionManagerClient.prototype.recv_extensions = function(input,mtype,rseqid) { 818 | var callback = this._reqs[rseqid] || function() {}; 819 | delete this._reqs[rseqid]; 820 | if (mtype == Thrift.MessageType.EXCEPTION) { 821 | var x = new Thrift.TApplicationException(); 822 | x.read(input); 823 | input.readMessageEnd(); 824 | return callback(x); 825 | } 826 | var result = new ExtensionManager_extensions_result(); 827 | result.read(input); 828 | input.readMessageEnd(); 829 | 830 | if (null !== result.success) { 831 | return callback(null, result.success); 832 | } 833 | return callback('extensions failed: unknown result'); 834 | }; 835 | ExtensionManagerClient.prototype.options = function(callback) { 836 | this._seqid = this.new_seqid(); 837 | if (callback === undefined) { 838 | var _defer = Q.defer(); 839 | this._reqs[this.seqid()] = function(error, result) { 840 | if (error) { 841 | _defer.reject(error); 842 | } else { 843 | _defer.resolve(result); 844 | } 845 | }; 846 | this.send_options(); 847 | return _defer.promise; 848 | } else { 849 | this._reqs[this.seqid()] = callback; 850 | this.send_options(); 851 | } 852 | }; 853 | 854 | ExtensionManagerClient.prototype.send_options = function() { 855 | var output = new this.pClass(this.output); 856 | output.writeMessageBegin('options', Thrift.MessageType.CALL, this.seqid()); 857 | var args = new ExtensionManager_options_args(); 858 | args.write(output); 859 | output.writeMessageEnd(); 860 | return this.output.flush(); 861 | }; 862 | 863 | ExtensionManagerClient.prototype.recv_options = function(input,mtype,rseqid) { 864 | var callback = this._reqs[rseqid] || function() {}; 865 | delete this._reqs[rseqid]; 866 | if (mtype == Thrift.MessageType.EXCEPTION) { 867 | var x = new Thrift.TApplicationException(); 868 | x.read(input); 869 | input.readMessageEnd(); 870 | return callback(x); 871 | } 872 | var result = new ExtensionManager_options_result(); 873 | result.read(input); 874 | input.readMessageEnd(); 875 | 876 | if (null !== result.success) { 877 | return callback(null, result.success); 878 | } 879 | return callback('options failed: unknown result'); 880 | }; 881 | ExtensionManagerClient.prototype.registerExtension = function(info, registry, callback) { 882 | this._seqid = this.new_seqid(); 883 | if (callback === undefined) { 884 | var _defer = Q.defer(); 885 | this._reqs[this.seqid()] = function(error, result) { 886 | if (error) { 887 | _defer.reject(error); 888 | } else { 889 | _defer.resolve(result); 890 | } 891 | }; 892 | this.send_registerExtension(info, registry); 893 | return _defer.promise; 894 | } else { 895 | this._reqs[this.seqid()] = callback; 896 | this.send_registerExtension(info, registry); 897 | } 898 | }; 899 | 900 | ExtensionManagerClient.prototype.send_registerExtension = function(info, registry) { 901 | var output = new this.pClass(this.output); 902 | output.writeMessageBegin('registerExtension', Thrift.MessageType.CALL, this.seqid()); 903 | var args = new ExtensionManager_registerExtension_args(); 904 | args.info = info; 905 | args.registry = registry; 906 | args.write(output); 907 | output.writeMessageEnd(); 908 | return this.output.flush(); 909 | }; 910 | 911 | ExtensionManagerClient.prototype.recv_registerExtension = function(input,mtype,rseqid) { 912 | var callback = this._reqs[rseqid] || function() {}; 913 | delete this._reqs[rseqid]; 914 | if (mtype == Thrift.MessageType.EXCEPTION) { 915 | var x = new Thrift.TApplicationException(); 916 | x.read(input); 917 | input.readMessageEnd(); 918 | return callback(x); 919 | } 920 | var result = new ExtensionManager_registerExtension_result(); 921 | result.read(input); 922 | input.readMessageEnd(); 923 | 924 | if (null !== result.success) { 925 | return callback(null, result.success); 926 | } 927 | return callback('registerExtension failed: unknown result'); 928 | }; 929 | ExtensionManagerClient.prototype.deregisterExtension = function(uuid, callback) { 930 | this._seqid = this.new_seqid(); 931 | if (callback === undefined) { 932 | var _defer = Q.defer(); 933 | this._reqs[this.seqid()] = function(error, result) { 934 | if (error) { 935 | _defer.reject(error); 936 | } else { 937 | _defer.resolve(result); 938 | } 939 | }; 940 | this.send_deregisterExtension(uuid); 941 | return _defer.promise; 942 | } else { 943 | this._reqs[this.seqid()] = callback; 944 | this.send_deregisterExtension(uuid); 945 | } 946 | }; 947 | 948 | ExtensionManagerClient.prototype.send_deregisterExtension = function(uuid) { 949 | var output = new this.pClass(this.output); 950 | output.writeMessageBegin('deregisterExtension', Thrift.MessageType.CALL, this.seqid()); 951 | var args = new ExtensionManager_deregisterExtension_args(); 952 | args.uuid = uuid; 953 | args.write(output); 954 | output.writeMessageEnd(); 955 | return this.output.flush(); 956 | }; 957 | 958 | ExtensionManagerClient.prototype.recv_deregisterExtension = function(input,mtype,rseqid) { 959 | var callback = this._reqs[rseqid] || function() {}; 960 | delete this._reqs[rseqid]; 961 | if (mtype == Thrift.MessageType.EXCEPTION) { 962 | var x = new Thrift.TApplicationException(); 963 | x.read(input); 964 | input.readMessageEnd(); 965 | return callback(x); 966 | } 967 | var result = new ExtensionManager_deregisterExtension_result(); 968 | result.read(input); 969 | input.readMessageEnd(); 970 | 971 | if (null !== result.success) { 972 | return callback(null, result.success); 973 | } 974 | return callback('deregisterExtension failed: unknown result'); 975 | }; 976 | ExtensionManagerClient.prototype.query = function(sql, callback) { 977 | this._seqid = this.new_seqid(); 978 | if (callback === undefined) { 979 | var _defer = Q.defer(); 980 | this._reqs[this.seqid()] = function(error, result) { 981 | if (error) { 982 | _defer.reject(error); 983 | } else { 984 | _defer.resolve(result); 985 | } 986 | }; 987 | this.send_query(sql); 988 | return _defer.promise; 989 | } else { 990 | this._reqs[this.seqid()] = callback; 991 | this.send_query(sql); 992 | } 993 | }; 994 | 995 | ExtensionManagerClient.prototype.send_query = function(sql) { 996 | var output = new this.pClass(this.output); 997 | output.writeMessageBegin('query', Thrift.MessageType.CALL, this.seqid()); 998 | var args = new ExtensionManager_query_args(); 999 | args.sql = sql; 1000 | args.write(output); 1001 | output.writeMessageEnd(); 1002 | return this.output.flush(); 1003 | }; 1004 | 1005 | ExtensionManagerClient.prototype.recv_query = function(input,mtype,rseqid) { 1006 | var callback = this._reqs[rseqid] || function() {}; 1007 | delete this._reqs[rseqid]; 1008 | if (mtype == Thrift.MessageType.EXCEPTION) { 1009 | var x = new Thrift.TApplicationException(); 1010 | x.read(input); 1011 | input.readMessageEnd(); 1012 | return callback(x); 1013 | } 1014 | var result = new ExtensionManager_query_result(); 1015 | result.read(input); 1016 | input.readMessageEnd(); 1017 | 1018 | if (null !== result.success) { 1019 | return callback(null, result.success); 1020 | } 1021 | return callback('query failed: unknown result'); 1022 | }; 1023 | ExtensionManagerClient.prototype.getQueryColumns = function(sql, callback) { 1024 | this._seqid = this.new_seqid(); 1025 | if (callback === undefined) { 1026 | var _defer = Q.defer(); 1027 | this._reqs[this.seqid()] = function(error, result) { 1028 | if (error) { 1029 | _defer.reject(error); 1030 | } else { 1031 | _defer.resolve(result); 1032 | } 1033 | }; 1034 | this.send_getQueryColumns(sql); 1035 | return _defer.promise; 1036 | } else { 1037 | this._reqs[this.seqid()] = callback; 1038 | this.send_getQueryColumns(sql); 1039 | } 1040 | }; 1041 | 1042 | ExtensionManagerClient.prototype.send_getQueryColumns = function(sql) { 1043 | var output = new this.pClass(this.output); 1044 | output.writeMessageBegin('getQueryColumns', Thrift.MessageType.CALL, this.seqid()); 1045 | var args = new ExtensionManager_getQueryColumns_args(); 1046 | args.sql = sql; 1047 | args.write(output); 1048 | output.writeMessageEnd(); 1049 | return this.output.flush(); 1050 | }; 1051 | 1052 | ExtensionManagerClient.prototype.recv_getQueryColumns = function(input,mtype,rseqid) { 1053 | var callback = this._reqs[rseqid] || function() {}; 1054 | delete this._reqs[rseqid]; 1055 | if (mtype == Thrift.MessageType.EXCEPTION) { 1056 | var x = new Thrift.TApplicationException(); 1057 | x.read(input); 1058 | input.readMessageEnd(); 1059 | return callback(x); 1060 | } 1061 | var result = new ExtensionManager_getQueryColumns_result(); 1062 | result.read(input); 1063 | input.readMessageEnd(); 1064 | 1065 | if (null !== result.success) { 1066 | return callback(null, result.success); 1067 | } 1068 | return callback('getQueryColumns failed: unknown result'); 1069 | }; 1070 | ExtensionManagerProcessor = exports.Processor = function(handler) { 1071 | this._handler = handler 1072 | } 1073 | Thrift.inherits(ExtensionManagerProcessor, ExtensionProcessor) 1074 | ExtensionManagerProcessor.prototype.process = function(input, output) { 1075 | var r = input.readMessageBegin(); 1076 | if (this['process_' + r.fname]) { 1077 | return this['process_' + r.fname].call(this, r.rseqid, input, output); 1078 | } else { 1079 | input.skip(Thrift.Type.STRUCT); 1080 | input.readMessageEnd(); 1081 | var x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname); 1082 | output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid); 1083 | x.write(output); 1084 | output.writeMessageEnd(); 1085 | output.flush(); 1086 | } 1087 | } 1088 | 1089 | ExtensionManagerProcessor.prototype.process_extensions = function(seqid, input, output) { 1090 | var args = new ExtensionManager_extensions_args(); 1091 | args.read(input); 1092 | input.readMessageEnd(); 1093 | if (this._handler.extensions.length === 0) { 1094 | Q.fcall(this._handler.extensions) 1095 | .then(function(result) { 1096 | var result = new ExtensionManager_extensions_result({success: result}); 1097 | output.writeMessageBegin("extensions", Thrift.MessageType.REPLY, seqid); 1098 | result.write(output); 1099 | output.writeMessageEnd(); 1100 | output.flush(); 1101 | }, function (err) { 1102 | var result = new ExtensionManager_extensions_result(err); 1103 | output.writeMessageBegin("extensions", Thrift.MessageType.REPLY, seqid); 1104 | result.write(output); 1105 | output.writeMessageEnd(); 1106 | output.flush(); 1107 | }); 1108 | } else { 1109 | this._handler.extensions( function (err, result) { 1110 | var result = new ExtensionManager_extensions_result((err != null ? err : {success: result})); 1111 | output.writeMessageBegin("extensions", Thrift.MessageType.REPLY, seqid); 1112 | result.write(output); 1113 | output.writeMessageEnd(); 1114 | output.flush(); 1115 | }); 1116 | } 1117 | } 1118 | 1119 | ExtensionManagerProcessor.prototype.process_options = function(seqid, input, output) { 1120 | var args = new ExtensionManager_options_args(); 1121 | args.read(input); 1122 | input.readMessageEnd(); 1123 | if (this._handler.options.length === 0) { 1124 | Q.fcall(this._handler.options) 1125 | .then(function(result) { 1126 | var result = new ExtensionManager_options_result({success: result}); 1127 | output.writeMessageBegin("options", Thrift.MessageType.REPLY, seqid); 1128 | result.write(output); 1129 | output.writeMessageEnd(); 1130 | output.flush(); 1131 | }, function (err) { 1132 | var result = new ExtensionManager_options_result(err); 1133 | output.writeMessageBegin("options", Thrift.MessageType.REPLY, seqid); 1134 | result.write(output); 1135 | output.writeMessageEnd(); 1136 | output.flush(); 1137 | }); 1138 | } else { 1139 | this._handler.options( function (err, result) { 1140 | var result = new ExtensionManager_options_result((err != null ? err : {success: result})); 1141 | output.writeMessageBegin("options", Thrift.MessageType.REPLY, seqid); 1142 | result.write(output); 1143 | output.writeMessageEnd(); 1144 | output.flush(); 1145 | }); 1146 | } 1147 | } 1148 | 1149 | ExtensionManagerProcessor.prototype.process_registerExtension = function(seqid, input, output) { 1150 | var args = new ExtensionManager_registerExtension_args(); 1151 | args.read(input); 1152 | input.readMessageEnd(); 1153 | if (this._handler.registerExtension.length === 2) { 1154 | Q.fcall(this._handler.registerExtension, args.info, args.registry) 1155 | .then(function(result) { 1156 | var result = new ExtensionManager_registerExtension_result({success: result}); 1157 | output.writeMessageBegin("registerExtension", Thrift.MessageType.REPLY, seqid); 1158 | result.write(output); 1159 | output.writeMessageEnd(); 1160 | output.flush(); 1161 | }, function (err) { 1162 | var result = new ExtensionManager_registerExtension_result(err); 1163 | output.writeMessageBegin("registerExtension", Thrift.MessageType.REPLY, seqid); 1164 | result.write(output); 1165 | output.writeMessageEnd(); 1166 | output.flush(); 1167 | }); 1168 | } else { 1169 | this._handler.registerExtension(args.info, args.registry, function (err, result) { 1170 | var result = new ExtensionManager_registerExtension_result((err != null ? err : {success: result})); 1171 | output.writeMessageBegin("registerExtension", Thrift.MessageType.REPLY, seqid); 1172 | result.write(output); 1173 | output.writeMessageEnd(); 1174 | output.flush(); 1175 | }); 1176 | } 1177 | } 1178 | 1179 | ExtensionManagerProcessor.prototype.process_deregisterExtension = function(seqid, input, output) { 1180 | var args = new ExtensionManager_deregisterExtension_args(); 1181 | args.read(input); 1182 | input.readMessageEnd(); 1183 | if (this._handler.deregisterExtension.length === 1) { 1184 | Q.fcall(this._handler.deregisterExtension, args.uuid) 1185 | .then(function(result) { 1186 | var result = new ExtensionManager_deregisterExtension_result({success: result}); 1187 | output.writeMessageBegin("deregisterExtension", Thrift.MessageType.REPLY, seqid); 1188 | result.write(output); 1189 | output.writeMessageEnd(); 1190 | output.flush(); 1191 | }, function (err) { 1192 | var result = new ExtensionManager_deregisterExtension_result(err); 1193 | output.writeMessageBegin("deregisterExtension", Thrift.MessageType.REPLY, seqid); 1194 | result.write(output); 1195 | output.writeMessageEnd(); 1196 | output.flush(); 1197 | }); 1198 | } else { 1199 | this._handler.deregisterExtension(args.uuid, function (err, result) { 1200 | var result = new ExtensionManager_deregisterExtension_result((err != null ? err : {success: result})); 1201 | output.writeMessageBegin("deregisterExtension", Thrift.MessageType.REPLY, seqid); 1202 | result.write(output); 1203 | output.writeMessageEnd(); 1204 | output.flush(); 1205 | }); 1206 | } 1207 | } 1208 | 1209 | ExtensionManagerProcessor.prototype.process_query = function(seqid, input, output) { 1210 | var args = new ExtensionManager_query_args(); 1211 | args.read(input); 1212 | input.readMessageEnd(); 1213 | if (this._handler.query.length === 1) { 1214 | Q.fcall(this._handler.query, args.sql) 1215 | .then(function(result) { 1216 | var result = new ExtensionManager_query_result({success: result}); 1217 | output.writeMessageBegin("query", Thrift.MessageType.REPLY, seqid); 1218 | result.write(output); 1219 | output.writeMessageEnd(); 1220 | output.flush(); 1221 | }, function (err) { 1222 | var result = new ExtensionManager_query_result(err); 1223 | output.writeMessageBegin("query", Thrift.MessageType.REPLY, seqid); 1224 | result.write(output); 1225 | output.writeMessageEnd(); 1226 | output.flush(); 1227 | }); 1228 | } else { 1229 | this._handler.query(args.sql, function (err, result) { 1230 | var result = new ExtensionManager_query_result((err != null ? err : {success: result})); 1231 | output.writeMessageBegin("query", Thrift.MessageType.REPLY, seqid); 1232 | result.write(output); 1233 | output.writeMessageEnd(); 1234 | output.flush(); 1235 | }); 1236 | } 1237 | } 1238 | 1239 | ExtensionManagerProcessor.prototype.process_getQueryColumns = function(seqid, input, output) { 1240 | var args = new ExtensionManager_getQueryColumns_args(); 1241 | args.read(input); 1242 | input.readMessageEnd(); 1243 | if (this._handler.getQueryColumns.length === 1) { 1244 | Q.fcall(this._handler.getQueryColumns, args.sql) 1245 | .then(function(result) { 1246 | var result = new ExtensionManager_getQueryColumns_result({success: result}); 1247 | output.writeMessageBegin("getQueryColumns", Thrift.MessageType.REPLY, seqid); 1248 | result.write(output); 1249 | output.writeMessageEnd(); 1250 | output.flush(); 1251 | }, function (err) { 1252 | var result = new ExtensionManager_getQueryColumns_result(err); 1253 | output.writeMessageBegin("getQueryColumns", Thrift.MessageType.REPLY, seqid); 1254 | result.write(output); 1255 | output.writeMessageEnd(); 1256 | output.flush(); 1257 | }); 1258 | } else { 1259 | this._handler.getQueryColumns(args.sql, function (err, result) { 1260 | var result = new ExtensionManager_getQueryColumns_result((err != null ? err : {success: result})); 1261 | output.writeMessageBegin("getQueryColumns", Thrift.MessageType.REPLY, seqid); 1262 | result.write(output); 1263 | output.writeMessageEnd(); 1264 | output.flush(); 1265 | }); 1266 | } 1267 | } 1268 | 1269 | --------------------------------------------------------------------------------