Upgrading vendor folder dependencies.

This commit is contained in:
Renan DelValle 2018-12-27 09:58:53 -08:00
parent 4a0cbcd770
commit acbe9ad9e5
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
229 changed files with 10735 additions and 4528 deletions

View file

@ -0,0 +1 @@
test-compiled/

45
vendor/git.apache.org/thrift.git/lib/nodets/Makefile.am generated vendored Executable file
View file

@ -0,0 +1,45 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# We call npm twice to work around npm issues
stubs: $(top_srcdir)/test/ThriftTest.thrift
mkdir -p test-compiled
$(THRIFT) --gen js:node,ts -o test/ $(top_srcdir)/test/ThriftTest.thrift && $(THRIFT) --gen js:node,ts -o test-compiled $(top_srcdir)/test/ThriftTest.thrift
ts-compile: stubs
mkdir -p test-compiled
../../node_modules/typescript/bin/tsc --outDir test-compiled/ --project test/tsconfig.json
deps: $(top_srcdir)/package.json
$(NPM) install $(top_srcdir)/ || $(NPM) install $(top_srcdir)/
all-local: deps ts-compile
precross: deps stubs ts-compile
check: deps ts-compile
cd $(top_srcdir) && $(NPM) run test-ts && cd lib/nodets
clean-local:
$(RM) -r test/gen-nodejs
$(RM) -r $(top_srcdir)/node_modules
$(RM) -r test-compiled
EXTRA_DIST = \
test \
coding_standards.md

View file

@ -0,0 +1 @@
Please follow [General Coding Standards](/doc/coding_standards.md)

View file

@ -0,0 +1,63 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import assert = require("assert");
import thrift = require("thrift");
import Thrift = thrift.Thrift;
import ThriftTest = require("./gen-nodejs/ThriftTest");
import test_driver = require("./test_driver");
import ThriftTestDriver = test_driver.ThriftTestDriver;
import ThriftTestDriverPromise = test_driver.ThriftTestDriverPromise;
// var program = require("commander");
import * as program from "commander";
program
.option("--port <port>", "Set thrift server port number to connect", 9090)
.option("--promise", "test with promise style functions")
.option("--protocol", "Set thrift protocol (binary) [protocol]")
.parse(process.argv);
var port: number = program.port;
var promise = program.promise;
var options = {
transport: Thrift.TBufferedTransport,
protocol: Thrift.TBinaryProtocol
};
var testDriver = promise ? ThriftTestDriverPromise : ThriftTestDriver;
var connection = thrift.createConnection("localhost", port, options);
connection.on("error", function(err: string) {
assert(false, err);
});
var client = thrift.createClient(ThriftTest.Client, connection);
runTests();
function runTests() {
testDriver(client, function (status: string) {
console.log(status);
process.exit(0);
});
}
exports.expressoTest = function() {};

View file

@ -0,0 +1,18 @@
#! /bin/sh
DIR="$( cd "$( dirname "$0" )" && pwd )"
mkdir -p $DIR/../test-compiled
COMPILEDDIR="$(cd $DIR && cd ../test-compiled && pwd)"
export NODE_PATH="${DIR}:${DIR}/../../nodejs/lib:${NODE_PATH}"
compile()
{
#generating thrift code
${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
${DIR}/../../../compiler/cpp/thrift -o ${COMPILEDDIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
}
compile
node ${COMPILEDDIR}/client.js $*

View file

@ -0,0 +1,20 @@
#! /bin/sh
DIR="$( cd "$( dirname "$0" )" && pwd )"
mkdir -p $DIR/../test-compiled
COMPILEDDIR="$(cd $DIR && cd ../test-compiled && pwd)"
export NODE_PATH="${DIR}:${DIR}/../../nodejs/lib:${NODE_PATH}"
compile()
{
#generating thrift code
${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
${DIR}/../../../compiler/cpp/thrift -o ${COMPILEDDIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
}
compile
node ${COMPILEDDIR}/server.js $*

View file

@ -0,0 +1,26 @@
import thrift = require("thrift");
var program = require('commander');
import ThriftTest = require('./gen-nodejs/ThriftTest');
import test_handler = require('./test_handler');
program
.option('--port <port>', 'Set thrift server port', 9090)
.option('--promise', 'test with promise style functions')
.option('--protocol', '"Set thrift protocol (binary) [protocol]"')
.parse(process.argv);
var port: number = program.port;
var options: thrift.ServerOptions = {
transport: thrift.TBufferedTransport,
protocol: thrift.TBinaryProtocol
};
var server: thrift.Server;
if (program.promise) {
server = thrift.createServer(ThriftTest.Processor, new test_handler.AsyncThriftTestHandler(), options);
} else {
server = thrift.createServer(ThriftTest.Processor, new test_handler.SyncThriftTestHandler(), options);
}
server.listen(port);

View file

@ -0,0 +1,113 @@
'use strict';
import ttypes = require('./gen-nodejs/ThriftTest_types');
//all Languages in UTF-8
/*jshint -W100 */
export var stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, " +
"Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, " +
"Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, " +
"বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, " +
"Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, " +
"Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, " +
"Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, " +
"Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, " +
"Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, " +
"Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, " +
"Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, " +
"ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, " +
"Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, " +
"Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa " +
"Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa " +
"Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, " +
"Norsk (nynorsk), Norsk (bokmål), Nouormand, Diné bizaad, " +
"Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, " +
"Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, " +
"Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple " +
"English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, " +
"Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, " +
"Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, " +
"Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, " +
"Bân-lâm-gú, 粵語";
/*jshint +W100 */
export var specialCharacters = 'quote: \" backslash:' +
' forwardslash-escaped: \/ ' +
' backspace: \b formfeed: \f newline: \n return: \r tab: ' +
' now-all-of-them-together: "\\\/\b\n\r\t' +
' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><' +
' char-to-test-json-parsing: ]] \"]] \\" }}}{ [[[ ';
export var mapTestInput = {
"a":"123", "a b":"with spaces ", "same":"same", "0":"numeric key",
"longValue":stringTest, stringTest:"long key"
};
export var simple = [
['testVoid', undefined],
['testString', 'Test'],
['testString', ''],
['testString', stringTest],
['testString', specialCharacters],
['testByte', 1],
['testByte', 0],
['testByte', -1],
['testByte', -127],
['testI32', -1],
['testDouble', -5.2098523],
['testDouble', 7.012052175215044],
['testEnum', ttypes.Numberz.ONE]
];
export var simpleLoose = [
['testI64', 5],
['testI64', -5],
['testI64', 734359738368],
['testI64', -34359738368],
['testI64', -734359738368],
['testTypedef', 69]
]
var mapout: {[key: number]: number; } = {};
for (var i = 0; i < 5; ++i) {
mapout[i] = i-10;
}
export var deep = [
['testMap', mapout],
['testSet', [1,2,3]],
['testList', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]],
['testStringMap', mapTestInput]
];
export var out = new ttypes.Xtruct({
string_thing: 'Zero',
byte_thing: 1,
i32_thing: -3,
i64_thing: 1000000
});
export var out2 = new ttypes.Xtruct2();
out2.byte_thing = 1;
out2.struct_thing = out;
out2.i32_thing = 5;
export var crazy = new ttypes.Insanity({
"userMap":{ "5":5, "8":8 },
"xtructs":[new ttypes.Xtruct({
"string_thing":"Goodbye4",
"byte_thing":4,
"i32_thing":4,
"i64_thing":4
}), new ttypes.Xtruct({
"string_thing":"Hello2",
"byte_thing":2,
"i32_thing":2,
"i64_thing":2
})]
});
export var insanity: any = {
"1":{ "2": crazy, "3": crazy },
"2":{ "6":{ "userMap":{}, "xtructs":[] } }
};

38
vendor/git.apache.org/thrift.git/lib/nodets/test/testAll.sh generated vendored Executable file
View file

@ -0,0 +1,38 @@
#! /bin/sh
DIR="$( cd "$( dirname "$0" )" && pwd )"
mkdir -p $DIR/../test-compiled
COMPILEDDIR="$(cd $DIR && cd ../test-compiled && pwd)"
export NODE_PATH="${DIR}:${DIR}/../../nodejs/lib:${NODE_PATH}"
compile()
{
#generating thrift code
${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
${DIR}/../../../compiler/cpp/thrift -o ${COMPILEDDIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
tsc --outDir $COMPILEDDIR --project $DIR/tsconfig.json
}
compile
testServer()
{
echo "start server $1"
RET=0
node ${COMPILEDDIR}/server.js $1 &
SERVERPID=$!
sleep 1
echo "start client $1"
node ${COMPILEDDIR}/client.js $1 || RET=1
kill -2 $SERVERPID || RET=1
return $RET
}
#integration tests
testServer || TESTOK=1
testServer --promise || TESTOK=1
exit $TESTOK

View file

@ -0,0 +1,278 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* 'License'); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// This is the Node.js test driver for the standard Apache Thrift
// test service. The driver invokes every function defined in the
// Thrift Test service with a representative range of parameters.
//
// The ThriftTestDriver function requires a client object
// connected to a server hosting the Thrift Test service and
// supports an optional callback function which is called with
// a status message when the test is complete.
import test = require("tape");
import ttypes = require("./gen-nodejs/ThriftTest_types");
import ThriftTest = require("./gen-nodejs/ThriftTest");
import thrift = require("thrift");
import Q = thrift.Q;
import TException = thrift.Thrift.TException;
var Int64 = require("node-int64");
import testCases = require("./test-cases");
export function ThriftTestDriver(client: ThriftTest.Client, callback: (status: string) => void) {
test("NodeJS Style Callback Client Tests", function(assert) {
var checkRecursively = makeRecursiveCheck(assert);
function makeAsserter(assertionFn: (a: any, b: any, msg?: string) => void) {
return function(c: (string | any)[]) {
var fnName = c[0];
var expected = c[1];
(<any>client)[fnName](expected, function(err: any, actual: any) {
assert.error(err, fnName + ": no callback error");
assertionFn(actual, expected, fnName);
})
};
}
testCases.simple.forEach(makeAsserter(assert.equal));
testCases.simpleLoose.forEach(makeAsserter(function(a, e, m){
assert.ok(a == e, m);
}));
testCases.deep.forEach(makeAsserter(assert.deepEqual));
client.testMapMap(42, function(err, response) {
var expected: typeof response = {
"4": {"1":1, "2":2, "3":3, "4":4},
"-4": {"-4":-4, "-3":-3, "-2":-2, "-1":-1}
};
assert.error(err, 'testMapMap: no callback error');
assert.deepEqual(expected, response, "testMapMap");
});
client.testStruct(testCases.out, function(err, response) {
assert.error(err, "testStruct: no callback error");
checkRecursively(testCases.out, response, "testStruct");
});
client.testNest(testCases.out2, function(err, response) {
assert.error(err, "testNest: no callback error");
checkRecursively(testCases.out2, response, "testNest");
});
client.testInsanity(testCases.crazy, function(err, response) {
assert.error(err, "testInsanity: no callback error");
checkRecursively(testCases.insanity, response, "testInsanity");
});
client.testException("TException", function(err, response) {
assert.ok(err instanceof TException, 'testException: correct error type');
assert.ok(!Boolean(response), 'testException: no response');
});
client.testException("Xception", function(err, response) {
assert.ok(err instanceof ttypes.Xception, 'testException: correct error type');
assert.ok(!Boolean(response), 'testException: no response');
assert.equal(err.errorCode, 1001, 'testException: correct error code');
assert.equal('Xception', err.message, 'testException: correct error message');
});
client.testException("no Exception", function(err, response) {
assert.error(err, 'testException: no callback error');
assert.ok(!Boolean(response), 'testException: no response');
});
client.testOneway(0, function(err, response) {
assert.error(err, 'testOneway: no callback error');
assert.strictEqual(response, undefined, 'testOneway: void response');
});
checkOffByOne(function(done) {
client.testI32(-1, function(err, response) {
assert.error(err, "checkOffByOne: no callback error");
assert.equal(-1, response);
assert.end();
done();
});
}, callback);
});
};
export function ThriftTestDriverPromise(client: ThriftTest.Client, callback: (status: string) => void) {
test("Q Promise Client Tests", function(assert) {
var checkRecursively = makeRecursiveCheck(assert);
function fail(msg: string) {
return function(error, response) {
if (error !== null) {
assert.fail(msg);
}
}
}
function makeAsserter(assertionFn: (a: any, b: any, msg?: string) => void) {
return function(c: (string | any)[]) {
var fnName = c[0];
var expected = c[1];
(<any>client)[fnName](expected)
.then(function(actual: any) {
assertionFn(actual, expected, fnName);
})
.fail(fail("fnName"));
};
}
testCases.simple.forEach(makeAsserter(assert.equal));
testCases.simpleLoose.forEach(makeAsserter(function(a, e, m){
assert.ok(a == e, m);
}));
testCases.deep.forEach(makeAsserter(assert.deepEqual));
Q.resolve(client.testStruct(testCases.out))
.then(function(response) {
checkRecursively(testCases.out, response, "testStruct");
})
.fail(fail("testStruct"));
Q.resolve(client.testNest(testCases.out2))
.then(function(response) {
checkRecursively(testCases.out2, response, "testNest");
})
.fail(fail("testNest"));
Q.resolve(client.testInsanity(testCases.crazy))
.then(function(response) {
checkRecursively(testCases.insanity, response, "testInsanity");
})
.fail(fail("testInsanity"));
Q.resolve(client.testException("TException"))
.then(function(response) {
fail("testException: TException");
})
.fail(function(err) {
assert.ok(err instanceof TException);
});
Q.resolve(client.testException("Xception"))
.then(function(response) {
fail("testException: Xception");
})
.fail(function(err) {
assert.ok(err instanceof ttypes.Xception);
assert.equal(err.errorCode, 1001);
assert.equal("Xception", err.message);
});
Q.resolve(client.testException("no Exception"))
.then(function(response) {
assert.equal(undefined, response); //void
})
.fail(fail("testException"));
client.testOneway(0, fail("testOneway: should not answer"));
checkOffByOne(function(done) {
Q.resolve(client.testI32(-1))
.then(function(response) {
assert.equal(-1, response);
assert.end();
done();
})
.fail(fail("checkOffByOne"));
}, callback);
});
};
// Helper Functions
// =========================================================
function makeRecursiveCheck(assert: test.Test) {
return function (map1: any, map2: any, msg: string) {
var equal = true;
var equal = checkRecursively(map1, map2);
assert.ok(equal, msg);
// deepEqual doesn't work with fields using node-int64
function checkRecursively(map1: any, map2: any) : boolean {
if (!(typeof map1 !== "function" && typeof map2 !== "function")) {
return false;
}
if (!map1 || typeof map1 !== "object") {
//Handle int64 types (which use node-int64 in Node.js JavaScript)
if ((typeof map1 === "number") && (typeof map2 === "object") &&
(map2.buffer) && (map2.buffer instanceof Buffer) && (map2.buffer.length === 8)) {
var n = new Int64(map2.buffer);
return map1 === n.toNumber();
} else {
return map1 == map2;
}
} else {
return Object.keys(map1).every(function(key) {
return checkRecursively(map1[key], map2[key]);
});
}
}
}
}
function checkOffByOne(done: (callback: () => void) => void, callback: (message: string) => void) {
var retry_limit = 30;
var retry_interval = 100;
var test_complete = false;
var retrys = 0;
/**
* redo a simple test after the oneway to make sure we aren't "off by one" --
* if the server treated oneway void like normal void, this next test will
* fail since it will get the void confirmation rather than the correct
* result. In this circumstance, the client will throw the exception:
*
* Because this is the last test against the server, when it completes
* the entire suite is complete by definition (the tests run serially).
*/
done(function() {
test_complete = true;
});
//We wait up to retry_limit * retry_interval for the test suite to complete
function TestForCompletion() {
if(test_complete && callback) {
callback("Server successfully tested!");
} else {
if (++retrys < retry_limit) {
setTimeout(TestForCompletion, retry_interval);
} else if (callback) {
callback("Server test failed to complete after " +
(retry_limit * retry_interval / 1000) + " seconds");
}
}
}
setTimeout(TestForCompletion, retry_interval);
}

View file

@ -0,0 +1,299 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* 'License'); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//This is the server side Node test handler for the standard
// Apache Thrift test service.
import ttypes = require("./gen-nodejs/ThriftTest_types");
import thrift = require("thrift");
import Thrift = thrift.Thrift;
import Q = require("q");
export class SyncThriftTestHandler {
testVoid(): Q.IPromise<void> {
//console.log('testVoid()');
return Q.resolve<void>(undefined);
}
testMapMap(hello: number) {
//console.log('testMapMap(' + hello + ')');
var mapmap: {[key: number]: {[key: number]: number; }} = [];
var pos: {[key: number]: number; } = [];
var neg: {[key: number]: number; } = [];
for (var i = 1; i < 5; i++) {
pos[i] = i;
neg[-i] = -i;
}
mapmap[4] = pos;
mapmap[-4] = neg;
return Q.resolve(mapmap);
}
testInsanity(argument: ttypes.Insanity): Q.IPromise<{ [k: number]: any; }> {
const first_map: { [k: number]: any; } = [];
const second_map: { [k: number]: any; } = [];
first_map[ttypes.Numberz.TWO] = argument;
first_map[ttypes.Numberz.THREE] = argument;
const looney = new ttypes.Insanity();
second_map[ttypes.Numberz.SIX] = looney;
const insane: { [k: number]: any; } = [];
insane[1] = first_map;
insane[2] = second_map;
return Q.resolve(insane);
}
testMulti(arg0: any, arg1: number, arg2: number, arg3: { [k: number]: string; }, arg4: ttypes.Numberz, arg5: number) {
var hello = new ttypes.Xtruct();
hello.string_thing = 'Hello2';
hello.byte_thing = arg0;
hello.i32_thing = arg1;
hello.i64_thing = arg2;
return Q.resolve(hello);
}
testException(arg: string): Q.IPromise<void> {
if (arg === 'Xception') {
var x = new ttypes.Xception();
x.errorCode = 1001;
x.message = arg;
throw x;
} else if (arg === 'TException') {
throw new Thrift.TException(arg);
} else {
return Q.resolve();
}
}
testMultiException(arg0: string, arg1: string) {
if (arg0 === ('Xception')) {
var x = new ttypes.Xception();
x.errorCode = 1001;
x.message = 'This is an Xception';
throw x;
} else if (arg0 === ('Xception2')) {
var x2 = new ttypes.Xception2();
x2.errorCode = 2002;
x2.struct_thing = new ttypes.Xtruct();
x2.struct_thing.string_thing = 'This is an Xception2';
throw x2;
}
var res = new ttypes.Xtruct();
res.string_thing = arg1;
return Q.resolve(res);
}
testOneway(sleepFor: number) {
}
testString(thing: string) {
return Q.resolve(thing);
}
testBool(thing: boolean) {
return Q.resolve(thing);
}
testByte(thing: number) {
return Q.resolve(thing);
}
testI32(thing: number) {
return Q.resolve(thing);
}
testI64(thing: number) {
return Q.resolve(thing);
}
testDouble(thing: number) {
return Q.resolve(thing);
}
testBinary(thing: Buffer) {
return Q.resolve(thing);
}
testStruct(thing: ttypes.Xtruct) {
return Q.resolve(thing);
}
testNest(thing: ttypes.Xtruct2) {
return Q.resolve(thing);
}
testMap(thing: { [k: number]: number; }) {
return Q.resolve(thing);
}
testStringMap(thing: { [k: string]: string; }) {
return Q.resolve(thing);
}
testSet(thing: number[]) {
return Q.resolve(thing);
}
testList(thing: number[]) {
return Q.resolve(thing);
}
testEnum(thing: ttypes.Numberz) {
return Q.resolve(thing);
}
testTypedef(thing: number) {
return Q.resolve(thing);
}
}
export class AsyncThriftTestHandler {
private syncHandler: SyncThriftTestHandler;
constructor() {
this.syncHandler = new SyncThriftTestHandler();
}
testVoid(callback: (result: void) => void): Q.IPromise<void> {
callback(undefined);
return Q.resolve();
}
testMapMap(hello: number,
callback: (err: any, result: { [k: number]: { [k: number]: number; }; }) => void):
Q.IPromise<{ [k: number]: { [k: number]: number; }; }> {
var mapmap: {[key: number]: {[key: number]: number; }} = [];
var pos: {[key: number]: number; } = [];
var neg: {[key: number]: number; } = [];
for (var i = 1; i < 5; i++) {
pos[i] = i;
neg[-i] = -i;
}
mapmap[4] = pos;
mapmap[-4] = neg;
callback(null, mapmap);
return Q.resolve();
}
testInsanity(argument: ttypes.Insanity, callback?: (err: any, result: { [k: number]: any; }) => void): Q.IPromise<{ [k: number]: any; }> {
const first_map: { [k: number]: any; } = [];
const second_map: { [k: number]: any; } = [];
first_map[ttypes.Numberz.TWO] = argument;
first_map[ttypes.Numberz.THREE] = argument;
const looney = new ttypes.Insanity();
second_map[ttypes.Numberz.SIX] = looney;
const insane: { [k: number]: any; } = [];
insane[1] = first_map;
insane[2] = second_map;
if (callback !== undefined){
callback(null, insane);
}
return Q.resolve();
}
testMulti(arg0: any, arg1: number, arg2: number, arg3: { [k: number]: string; }, arg4: ttypes.Numberz, arg5: number, result: Function): Q.IPromise<ttypes.Xtruct> {
var hello = this.syncHandler.testMulti(arg0, arg1, arg2, arg3, arg4, arg5);
hello.then(hello => result(null, hello));
return Q.resolve();
}
testException(arg: string, result: (err: any) => void): Q.IPromise<void> {
if (arg === 'Xception') {
var x = new ttypes.Xception();
x.errorCode = 1001;
x.message = arg;
result(x);
} else if (arg === 'TException') {
result(new Thrift.TException(arg));
} else {
result(null);
}
return Q.resolve();
}
testMultiException(arg0: string, arg1: string, result: (err: any, res?: ttypes.Xtruct) => void): Q.IPromise<ttypes.Xtruct> {
if (arg0 === ('Xception')) {
var x = new ttypes.Xception();
x.errorCode = 1001;
x.message = 'This is an Xception';
result(x);
} else if (arg0 === ('Xception2')) {
var x2 = new ttypes.Xception2();
x2.errorCode = 2002;
x2.struct_thing = new ttypes.Xtruct();
x2.struct_thing.string_thing = 'This is an Xception2';
result(x2);
} else {
var res = new ttypes.Xtruct();
res.string_thing = arg1;
result(null, res);
}
return Q.resolve();
}
testOneway(sleepFor: number, result: Function) {
this.syncHandler.testOneway(sleepFor);
}
testString(thing: string, callback: (err: any, result: string) => void): Q.IPromise<string> {
callback(null, thing);
return Q.resolve();
}
testByte(thing: number, callback: (err: any, result: number) => void): Q.IPromise<number> {
callback(null, thing);
return Q.resolve();
}
testBool(thing: boolean, callback: (err: any, result: boolean) => void ): Q.IPromise<boolean> {
callback(null, thing);
return Q.resolve();
}
testI32(thing: number, callback: (err: any, result: number) => void): Q.IPromise<number> {
callback(null, thing);
return Q.resolve();
}
testI64(thing: number, callback: (err: any, result: number) => void): Q.IPromise<number> {
callback(null, thing);
return Q.resolve();
}
testDouble(thing: number, callback: (err: any, result: number) => void): Q.IPromise<number> {
callback(null, thing);
return Q.resolve();
}
testBinary(thing: Buffer, callback: (err: any, result: Buffer) => void): Q.IPromise<Buffer> {
callback(null, thing);
return Q.resolve();
}
testStruct(thing: ttypes.Xtruct, callback: (err: any, result: ttypes.Xtruct) => void): Q.IPromise<ttypes.Xtruct> {
callback(null, thing);
return Q.resolve();
}
testNest(thing: ttypes.Xtruct2, callback: (err: any, result: ttypes.Xtruct2) => void): Q.IPromise<ttypes.Xtruct2> {
callback(null, thing);
return Q.resolve();
}
testMap(thing: { [k: number]: number; }, callback: (err: any, result: { [k: number]: number; }) => void): Q.IPromise<{ [k: number]: number; }> {
callback(null, thing);
return Q.resolve();
}
testStringMap(thing: { [k: string]: string; }, callback: (err: any, result: { [k: string]: string; }) => void): Q.IPromise<{ [k: string]: string; }> {
callback(null, thing);
return Q.resolve();
}
testSet(thing: number[], callback: (err: any, result: number[]) => void): Q.IPromise<number[]> {
callback(null, thing);
return Q.resolve();
}
testList(thing: number[], callback: (err: any, result: number[]) => void): Q.IPromise<number[]> {
callback(null, thing);
return Q.resolve();
}
testEnum(thing: ttypes.Numberz, callback: (err: any, result: ttypes.Numberz) => void): Q.IPromise<ttypes.Numberz> {
callback(null, thing);
return Q.resolve();
}
testTypedef(thing: number, callback: (err: any, result: number) => void): Q.IPromise<number> {
callback(null, thing);
return Q.resolve();
}
}

View file

@ -0,0 +1,22 @@
{
"compilerOptions": {
"allowJs": false,
"alwaysStrict": true,
"baseUrl": ".",
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"noImplicitThis": true,
"noUnusedLocals": true,
"preserveConstEnums": true,
"removeComments": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"target": "es6",
"paths": {
"thrift": ["../../nodejs/lib/thrift"]
}
}
}