THRIFT-5924: UUID support for NodeTS
Client: ts,js
Patch: CJCombrink
This closes #3331
diff --git a/lib/nodets/test/client.ts b/lib/nodets/test/client.ts
index c2666bc..99b5960 100644
--- a/lib/nodets/test/client.ts
+++ b/lib/nodets/test/client.ts
@@ -28,9 +28,10 @@
import { program } from "commander";
program
- .option("--port <port>", "Set thrift server port number to connect", Number.parseInt, 9090)
+ .option("--port <port>", "Set thrift server port number to connect", (v) => parseInt(v, 10), 9090)
.option("--promise", "test with promise style functions")
- .option("--protocol", "Set thrift protocol (binary) [protocol]")
+ .option('--protocol <protocol>', '"Set thrift protocol (binary) [protocol]"')
+ .option('--transport <transport>', '"Set thrift transport (buffered) [transport]"')
.parse(process.argv);
diff --git a/lib/nodets/test/runClient.sh b/lib/nodets/test/runClient.sh
index 9497da3..8d5e9a3 100755
--- a/lib/nodets/test/runClient.sh
+++ b/lib/nodets/test/runClient.sh
@@ -10,8 +10,8 @@
compile()
{
#generating thrift code
- ${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node,ts ${DIR}/../../../test/v0.16/ThriftTest.thrift
- ${DIR}/../../../compiler/cpp/thrift -o ${COMPILEDDIR} --gen js:node,ts ${DIR}/../../../test/v0.16/ThriftTest.thrift
+ ${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
diff --git a/lib/nodets/test/runServer.sh b/lib/nodets/test/runServer.sh
index ec26513..4eee927 100755
--- a/lib/nodets/test/runServer.sh
+++ b/lib/nodets/test/runServer.sh
@@ -10,8 +10,8 @@
compile()
{
#generating thrift code
- ${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node,ts ${DIR}/../../../test/v0.16/ThriftTest.thrift
- ${DIR}/../../../compiler/cpp/thrift -o ${COMPILEDDIR} --gen js:node,ts ${DIR}/../../../test/v0.16/ThriftTest.thrift
+ ${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
diff --git a/lib/nodets/test/server.ts b/lib/nodets/test/server.ts
index 5911384..a2ef5c6 100644
--- a/lib/nodets/test/server.ts
+++ b/lib/nodets/test/server.ts
@@ -5,9 +5,10 @@
program
- .option('--port <port>', 'Set thrift server port', Number.parseInt, 9090)
+ .option('--port <port>', 'Set thrift server port', (v) => parseInt(v, 10), 9090)
.option('--promise', 'test with promise style functions')
- .option('--protocol', '"Set thrift protocol (binary) [protocol]"')
+ .option('--protocol <protocol>', '"Set thrift protocol (binary) [protocol]"')
+ .option('--transport <transport>', '"Set thrift transport (buffered) [transport]"')
.parse(process.argv);
var opts = program.opts();
diff --git a/lib/nodets/test/test-cases.ts b/lib/nodets/test/test-cases.ts
index 98f54af..c836550 100644
--- a/lib/nodets/test/test-cases.ts
+++ b/lib/nodets/test/test-cases.ts
@@ -2,6 +2,7 @@
import ttypes = require("./gen-nodejs/ThriftTest_types");
import Int64 = require("node-int64");
+import { v4 as uuidv4, v7 as uuidv7 } from 'uuid';
//all Languages in UTF-8
/*jshint -W100 */
@@ -64,6 +65,9 @@
["testDouble", -5.2098523],
["testDouble", 7.012052175215044],
["testEnum", ttypes.Numberz.ONE],
+ ["testUuid", "00112233-4455-6677-8899-aabbccddeeff"],
+ ["testUuid", uuidv4()],
+ ["testUuid", uuidv7()],
];
export var simpleLoose = [
diff --git a/lib/nodets/test/testAll.sh b/lib/nodets/test/testAll.sh
index 8180e2a..3be12c3 100755
--- a/lib/nodets/test/testAll.sh
+++ b/lib/nodets/test/testAll.sh
@@ -10,9 +10,9 @@
compile()
{
#generating thrift code
- ${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node,ts ${DIR}/../../../test/v0.16/ThriftTest.thrift
+ ${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
${DIR}/../../../compiler/cpp/thrift -o ${DIR} --gen js:node,ts ${DIR}/../../../test/Int64Test.thrift
- ${DIR}/../../../compiler/cpp/thrift -o ${COMPILEDDIR} --gen js:node,ts ${DIR}/../../../test/v0.16/ThriftTest.thrift
+ ${DIR}/../../../compiler/cpp/thrift -o ${COMPILEDDIR} --gen js:node,ts ${DIR}/../../../test/ThriftTest.thrift
${DIR}/../../../compiler/cpp/thrift -o ${COMPILEDDIR} --gen js:node,ts ${DIR}/../../../test/Int64Test.thrift
tsc --outDir $COMPILEDDIR --project $DIR/tsconfig.json
diff --git a/lib/nodets/test/test_handler.ts b/lib/nodets/test/test_handler.ts
index 823b4e7..9e74a6b 100644
--- a/lib/nodets/test/test_handler.ts
+++ b/lib/nodets/test/test_handler.ts
@@ -25,6 +25,8 @@
import Thrift = thrift.Thrift;
import Q = require("q");
import Int64 = require("node-int64");
+import { v4 as uuid } from "uuid";
+type uuid = string;
export class SyncThriftTestHandler {
testVoid(): Q.IPromise<void> {
@@ -130,6 +132,9 @@
testBinary(thing: Buffer) {
return Q.resolve(thing);
}
+ testUuid(thing: uuid) {
+ return Q.resolve(thing);
+ }
testStruct(thing: ttypes.Xtruct) {
return Q.resolve(thing);
}
@@ -309,6 +314,13 @@
callback(null, thing);
return Q.resolve();
}
+ testUuid(
+ thing: uuid,
+ callback: (err: any, result: uuid) => void,
+ ): Q.IPromise<uuid> {
+ callback(null, thing);
+ return Q.resolve();
+ }
testStruct(
thing: ttypes.Xtruct,
callback: (err: any, result: ttypes.Xtruct) => void,