THRIFT-5924: UUID support for NodeTS
Client: ts,js
Patch: CJCombrink
This closes #3331
diff --git a/lib/nodejs/Makefile.am b/lib/nodejs/Makefile.am
index 0933701..ac19245 100644
--- a/lib/nodejs/Makefile.am
+++ b/lib/nodejs/Makefile.am
@@ -17,11 +17,8 @@
 
 # We call npm twice to work around npm issues
 
-stubs: $(top_srcdir)/test/v0.16/ThriftTest.thrift $(top_srcdir)/test/v0.16/FuzzTestNoUuid.thrift
-	$(THRIFT) --gen js:node -o test/ $(top_srcdir)/test/v0.16/ThriftTest.thrift
-	$(THRIFT) --gen js:node -o test/fuzz/ $(top_srcdir)/test/v0.16/FuzzTestNoUuid.thrift
-	sed -i "s/require('thrift')/require(\"..\/..\/..\/lib\/thrift\")/" test/fuzz/gen-nodejs/FuzzTestNoUuid_types.js
-
+stubs: $(top_srcdir)/test/ThriftTest.thrift
+	$(THRIFT) --gen js:node -o test/ $(top_srcdir)/test/ThriftTest.thrift
 
 deps-root: $(top_srcdir)/package.json
 	$(NPM) install $(top_srcdir)/ || $(NPM) install $(top_srcdir)/
diff --git a/lib/nodejs/lib/thrift/binary_protocol.js b/lib/nodejs/lib/thrift/binary_protocol.js
index fc4df4a..d5b2e14 100644
--- a/lib/nodejs/lib/thrift/binary_protocol.js
+++ b/lib/nodejs/lib/thrift/binary_protocol.js
@@ -23,6 +23,8 @@
 var Thrift = require("./thrift");
 var Type = Thrift.Type;
 
+const { parse: uuidParse, stringify: uuidStringify } = require("uuid");
+
 module.exports = TBinaryProtocol;
 
 // JavaScript supports only numeric doubles, therefore even hex values are always signed.
@@ -170,6 +172,10 @@
   this.writeStringOrBinary("writeBinary", "binary", arg);
 };
 
+TBinaryProtocol.prototype.writeUuid = function (arg) {
+  this.trans.write(Buffer.from(uuidParse(arg)));
+};
+
 TBinaryProtocol.prototype.readMessageBegin = function () {
   var sz = this.readI32();
   var type, name, seqid;
@@ -302,6 +308,11 @@
   return this.trans.readString(len);
 };
 
+TBinaryProtocol.prototype.readUuid = function () {
+  const buf = this.trans.read(16);
+  return uuidStringify(new Uint8Array(buf));
+};
+
 TBinaryProtocol.prototype.getTransport = function () {
   return this.trans;
 };
@@ -329,6 +340,9 @@
     case Type.STRING:
       this.readString();
       break;
+    case Type.UUID:
+      this.readUuid();
+      break;
     case Type.STRUCT:
       this.readStructBegin();
       while (true) {
diff --git a/lib/nodejs/lib/thrift/compact_protocol.js b/lib/nodejs/lib/thrift/compact_protocol.js
index e946dc8..dd7851e 100644
--- a/lib/nodejs/lib/thrift/compact_protocol.js
+++ b/lib/nodejs/lib/thrift/compact_protocol.js
@@ -22,6 +22,8 @@
 var Thrift = require("./thrift");
 var Type = Thrift.Type;
 
+const { parse: uuidParse, stringify: uuidStringify } = require("uuid");
+
 module.exports = TCompactProtocol;
 
 var POW_8 = Math.pow(2, 8);
@@ -120,6 +122,7 @@
  * @property {number}  CT_SET           - A collection type (unordered and without repeated values).
  * @property {number}  CT_MAP           - A collection type (map/associative-array/dictionary).
  * @property {number}  CT_STRUCT        - A multifield type.
+ * @property {number}  CT_UUID          - A UUID type.
  */
 TCompactProtocol.Types = {
   CT_STOP: 0x00,
@@ -135,6 +138,7 @@
   CT_SET: 0x0a,
   CT_MAP: 0x0b,
   CT_STRUCT: 0x0c,
+  CT_UUID: 0x0d,
 };
 
 /**
@@ -158,6 +162,7 @@
   TCompactProtocol.Types.CT_MAP, // T_MAP
   TCompactProtocol.Types.CT_SET, // T_SET
   TCompactProtocol.Types.CT_LIST, // T_LIST
+  TCompactProtocol.Types.CT_UUID, // T_UUID
 ];
 
 //
@@ -214,6 +219,8 @@
       return Type.MAP;
     case TCompactProtocol.Types.CT_STRUCT:
       return Type.STRUCT;
+    case TCompactProtocol.Types.CT_UUID:
+      return Type.UUID;
     default:
       throw new Thrift.TProtocolException(
         Thrift.TProtocolExceptionType.INVALID_DATA,
@@ -459,6 +466,10 @@
   this.writeStringOrBinary("writeBinary", "binary", arg);
 };
 
+TCompactProtocol.prototype.writeUuid = function (arg) {
+  this.trans.write(Buffer.from(uuidParse(arg)));
+};
+
 //
 // Compact Protocol internal write methods
 //
@@ -735,6 +746,11 @@
   return this.trans.readByte();
 };
 
+TCompactProtocol.prototype.readUuid = function () {
+  const buf = this.trans.read(16);
+  return uuidStringify(new Uint8Array(buf));
+};
+
 TCompactProtocol.prototype.readI16 = function () {
   return this.readI32();
 };
@@ -908,6 +924,9 @@
     case Type.STRING:
       this.readString();
       break;
+    case Type.UUID:
+      this.readUuid();
+      break;
     case Type.STRUCT:
       this.readStructBegin();
       while (true) {
diff --git a/lib/nodejs/lib/thrift/header_protocol.js b/lib/nodejs/lib/thrift/header_protocol.js
index 2a48a4d..7452925 100644
--- a/lib/nodejs/lib/thrift/header_protocol.js
+++ b/lib/nodejs/lib/thrift/header_protocol.js
@@ -158,6 +158,10 @@
   return this.protocol.writeBinary(arg);
 };
 
+THeaderProtocol.prototype.writeUuid = function (arg) {
+  return this.protocol.writeUuid(arg);
+};
+
 THeaderProtocol.prototype.readMessageBegin = function () {
   this.trans.readHeaders();
   this.setProtocol();
@@ -236,6 +240,10 @@
   return this.protocol.readBinary();
 };
 
+THeaderProtocol.prototype.readUuid = function () {
+  return this.protocol.readUuid();
+};
+
 THeaderProtocol.prototype.readString = function () {
   return this.protocol.readString();
 };
diff --git a/lib/nodejs/lib/thrift/json_protocol.js b/lib/nodejs/lib/thrift/json_protocol.js
index 31dcb81..176da38 100644
--- a/lib/nodejs/lib/thrift/json_protocol.js
+++ b/lib/nodejs/lib/thrift/json_protocol.js
@@ -62,6 +62,7 @@
 TJSONProtocol.Type[Type.MAP] = '"map"';
 TJSONProtocol.Type[Type.LIST] = '"lst"';
 TJSONProtocol.Type[Type.SET] = '"set"';
+TJSONProtocol.Type[Type.UUID] = '"uid"';
 
 /**
  * Thrift IDL type string to Id mapping.
@@ -80,6 +81,7 @@
 TJSONProtocol.RType.map = Type.MAP;
 TJSONProtocol.RType.lst = Type.LIST;
 TJSONProtocol.RType.set = Type.SET;
+TJSONProtocol.RType.uid = Type.UUID;
 
 /**
  * The TJSONProtocol version number.
@@ -424,6 +426,11 @@
   this.tstack.push('"' + buf.toString("base64") + '"');
 };
 
+/** Serializes a UUID */
+TJSONProtocol.prototype.writeUuid = function (arg) {
+  this.tstack.push('"' + arg + '"');
+};
+
 /**
  * @class
  * @name AnonReadMessageBeginReturn
@@ -758,6 +765,10 @@
   return this.readValue();
 };
 
+TJSONProtocol.prototype.readUuid = function() {
+  return this.readValue();
+};
+
 /**
  * Returns the underlying transport.
  * @readonly
@@ -793,6 +804,9 @@
     case Type.STRING:
       this.readString();
       break;
+    case Type.UUID:
+      this.readUuid();
+      break;
     case Type.STRUCT:
       this.readStructBegin();
       while (true) {
diff --git a/lib/nodejs/lib/thrift/thrift.js b/lib/nodejs/lib/thrift/thrift.js
index 741a493..ff6897d 100644
--- a/lib/nodejs/lib/thrift/thrift.js
+++ b/lib/nodejs/lib/thrift/thrift.js
@@ -34,8 +34,7 @@
   MAP: 13,
   SET: 14,
   LIST: 15,
-  UTF8: 16,
-  UTF16: 17,
+  UUID: 16,
 });
 
 exports.MessageType = {
diff --git a/lib/nodejs/test/certificates.README b/lib/nodejs/test/certificates.README
deleted file mode 100644
index 06c507e..0000000
--- a/lib/nodejs/test/certificates.README
+++ /dev/null
@@ -1,7 +0,0 @@
-server.crt AND server.key ARE PROVIDED FOR TEST PURPOSE AND SHOULD *NEVER* BE USED IN PRODUCTION
-
-
-Origin of the test key and cert is the folder test/keys of Apache Thrift source code distribution
-
-We need copies for npm deployment
-
diff --git a/lib/nodejs/test/client.mjs b/lib/nodejs/test/client.mjs
index 6200dc6..4c3ec43 100644
--- a/lib/nodejs/test/client.mjs
+++ b/lib/nodejs/test/client.mjs
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+import fs from "fs";
+import path from "path";
 import assert from "assert";
 import thrift from "thrift";
 import helpers from "./helpers.js";
@@ -93,7 +95,15 @@
 
 if (ssl) {
   if (type === "tcp" || type === "multiplex") {
+    options.secureProtocol = "TLS_method";
+    options.secureOptions = 0;
     options.rejectUnauthorized = false;
+    options.cert = fs.readFileSync(
+      path.resolve(import.meta.dirname, "../../../test/keys/client.crt"),
+    );
+    options.key = fs.readFileSync(
+      path.resolve(import.meta.dirname, "../../../test/keys/client.key"),
+    );
   } else if (type === "http") {
     options.nodeOptions = { rejectUnauthorized: false };
     options.https = true;
diff --git a/lib/nodejs/test/package-lock.json b/lib/nodejs/test/package-lock.json
index 6faee9d..bcd8e44 100644
--- a/lib/nodejs/test/package-lock.json
+++ b/lib/nodejs/test/package-lock.json
@@ -9,6 +9,7 @@
       }
     },
     "../../..": {
+      "name": "thrift",
       "version": "0.23.0",
       "dev": true,
       "license": "Apache-2.0",
@@ -17,6 +18,7 @@
         "isomorphic-ws": "^4.0.1",
         "node-int64": "^0.4.0",
         "q": "^1.5.0",
+        "uuid": "^13.0.0",
         "ws": "^5.2.3"
       },
       "devDependencies": {
diff --git a/lib/nodejs/test/server.crt b/lib/nodejs/test/server.crt
deleted file mode 100644
index 8a5ef3c..0000000
--- a/lib/nodejs/test/server.crt
+++ /dev/null
@@ -1,25 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIENzCCAx+gAwIBAgIJAOYfYfw7NCOcMA0GCSqGSIb3DQEBBQUAMIGxMQswCQYD
-VQQGEwJVUzERMA8GA1UECAwITWFyeWxhbmQxFDASBgNVBAcMC0ZvcmVzdCBIaWxs
-MScwJQYDVQQKDB5UaGUgQXBhY2hlIFNvZnR3YXJlIEZvdW5kYXRpb24xFjAUBgNV
-BAsMDUFwYWNoZSBUaHJpZnQxEjAQBgNVBAMMCWxvY2FsaG9zdDEkMCIGCSqGSIb3
-DQEJARYVZGV2QHRocmlmdC5hcGFjaGUub3JnMB4XDTE0MDQwNzE4NTgwMFoXDTIy
-MDYyNDE4NTgwMFowgbExCzAJBgNVBAYTAlVTMREwDwYDVQQIDAhNYXJ5bGFuZDEU
-MBIGA1UEBwwLRm9yZXN0IEhpbGwxJzAlBgNVBAoMHlRoZSBBcGFjaGUgU29mdHdh
-cmUgRm91bmRhdGlvbjEWMBQGA1UECwwNQXBhY2hlIFRocmlmdDESMBAGA1UEAwwJ
-bG9jYWxob3N0MSQwIgYJKoZIhvcNAQkBFhVkZXZAdGhyaWZ0LmFwYWNoZS5vcmcw
-ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqE9TE9wEXp5LRtLQVDSGQ
-GV78+7ZtP/I/ZaJ6Q6ZGlfxDFvZjFF73seNhAvlKlYm/jflIHYLnNOCySN8I2Xw6
-L9MbC+jvwkEKfQo4eDoxZnOZjNF5J1/lZtBeOowMkhhzBMH1Rds351/HjKNg6ZKg
-2Cldd0j7HbDtEixOLgLbPRpBcaYrLrNMasf3Hal+x8/b8ue28x93HSQBGmZmMIUw
-AinEu/fNP4lLGl/0kZb76TnyRpYSPYojtS6CnkH+QLYnsRREXJYwD1Xku62LipkX
-wCkRTnZ5nUsDMX6FPKgjQFQCWDXG/N096+PRUQAChhrXsJ+gF3NqWtDmtrhVQF4n
-AgMBAAGjUDBOMB0GA1UdDgQWBBQo8v0wzQPx3EEexJPGlxPK1PpgKjAfBgNVHSME
-GDAWgBQo8v0wzQPx3EEexJPGlxPK1PpgKjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3
-DQEBBQUAA4IBAQBGFRiJslcX0aJkwZpzTwSUdgcfKbpvNEbCNtVohfQVTI4a/oN5
-U+yqDZJg3vOaOuiAZqyHcIlZ8qyesCgRN314Tl4/JQ++CW8mKj1meTgo5YFxcZYm
-T9vsI3C+Nzn84DINgI9mx6yktIt3QOKZRDpzyPkUzxsyJ8J427DaimDrjTR+fTwD
-1Dh09xeeMnSa5zeV1HEDyJTqCXutLetwQ/IyfmMBhIx+nvB5f67pz/m+Dv6V0r3I
-p4HCcdnDUDGJbfqtoqsAATQQWO+WWuswB6mOhDbvPTxhRpZq6AkgWqv4S+u3M2GO
-r5p9FrBgavAw5bKO54C0oQKpN/5fta5l6Ws0
------END CERTIFICATE-----
diff --git a/lib/nodejs/test/server.key b/lib/nodejs/test/server.key
deleted file mode 100644
index 263cfce..0000000
--- a/lib/nodejs/test/server.key
+++ /dev/null
@@ -1,28 +0,0 @@
------BEGIN PRIVATE KEY-----
-MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCqE9TE9wEXp5LR
-tLQVDSGQGV78+7ZtP/I/ZaJ6Q6ZGlfxDFvZjFF73seNhAvlKlYm/jflIHYLnNOCy
-SN8I2Xw6L9MbC+jvwkEKfQo4eDoxZnOZjNF5J1/lZtBeOowMkhhzBMH1Rds351/H
-jKNg6ZKg2Cldd0j7HbDtEixOLgLbPRpBcaYrLrNMasf3Hal+x8/b8ue28x93HSQB
-GmZmMIUwAinEu/fNP4lLGl/0kZb76TnyRpYSPYojtS6CnkH+QLYnsRREXJYwD1Xk
-u62LipkXwCkRTnZ5nUsDMX6FPKgjQFQCWDXG/N096+PRUQAChhrXsJ+gF3NqWtDm
-trhVQF4nAgMBAAECggEAW/y52YYW6ypROGbZ94DQpFV0kLO7qT8q0Ksxw5sPNaIt
-fEPRIymDa8ikyHWJS5Oxmw84wo5jnJV26jaLmwe2Lupq7Xf1lqej8f5LJtuv7cQR
-xfzp1vM65KJFFJHp6WqjGqJ6HSSZOpVDsnQYcXQjQCdpyAmaSWd3p+FqYSZ1mQmD
-bFNI7jqpczWSZhTdotQ7p7Hn9TVCehflP3yGIB3bQ+wCcCB85dOBz201L+YgaIck
-Sz43A4NvWaQIRLRDw7s9GW4jY5T0Jv282WIeAlVpVxLIwu48r4R4yGTIx9Ydowvq
-57+Y5iPPjAXxu0V9t00oS3bYxDaKh2DUfc/5zowq8QKBgQDYNVPXmaG0aIH4vjQ9
-7fRdw/UDkYcQbn6CnglQOu77/S8ogQzpKCVJgJgkZNqOVtQMEPzekGEcLTbje1gU
-8Bky2k+PL9UwbFy0emnOVh4rqrNXHsRvJcehNT/PRb5hjF3MUMFV/0iD4b+naFaE
-jrSWiZ2ZXj2qfwAK52GFbtOuBQKBgQDJYQuGiY0r22E4waJmCSKczoBT3cwlVzWj
-V2ljgA9RHLNTVkvNNYQLGu2qngFrtwpeaSnsMDerVG4wKAQWyCnYzxVrlnC4uDrJ
-HXuFEltBWi9Ffbgfsnd3749AT0oBP1NT2tMleguyf5DFgjCR3VRJLdrVaaZ8row/
-LqKcFMqnOwKBgB+OIO99l7E584Y3VG6ZdSneOLtNmRXX2pT7tcZE465ZdHGH7Dd3
-SYHhx9K/+Xn+yDH+pLli/xlarAEldmSP6k2WuTfftlC78AfTOfAId5zN7CDR9791
-Fx67I9X/itq33tS8EIuZl57P6uXm/4GXRloWOa8xpvRkVsBApuYPl8t1AoGATQDS
-y2sllDObBXzlgGbV2WgNIgSZ311toTv3jJiXQsjauW8yJRHln+l4H9mzaWDgkiFc
-ang1kUoDqF5k0eFQPxtQcYdhKwEnWWfwp33RbzfxA32DPnubuzzbZhfrkHaKgnIW
-cyor9uFYlm2l7ODZLfJez2RKyTplXnOSsmQw6akCgYAz3dj9Hskyj+HVJ+ht1OcE
-c7ai/ESkSA7Vajp0tjJp0EKjW/zq8DvUSXOtcdnJgkKycFluLwbmnaN4txBds1C1
-Qr8Rt2sUCCBNZe1L6DHe3XBdbkJe9sgZVNTjtUSQrzy8UhvsCqG4YWeCu07Szcbc
-rdPUV9/uQkdx8VrShxlD8A==
------END PRIVATE KEY-----
diff --git a/lib/nodejs/test/server.mjs b/lib/nodejs/test/server.mjs
index 7a3c593..4b198a1 100644
--- a/lib/nodejs/test/server.mjs
+++ b/lib/nodejs/test/server.mjs
@@ -119,8 +119,12 @@
     type === "websocket"
   ) {
     options.tls = {
-      key: fs.readFileSync(path.resolve(import.meta.dirname, "server.key")),
-      cert: fs.readFileSync(path.resolve(import.meta.dirname, "server.crt")),
+      key: fs.readFileSync(
+        path.resolve(import.meta.dirname, "../../../test/keys/server.key"),
+      ),
+      cert: fs.readFileSync(
+        path.resolve(import.meta.dirname, "../../../test/keys/server.crt"),
+      ),
     };
   }
 }
diff --git a/lib/nodejs/test/test-cases.mjs b/lib/nodejs/test/test-cases.mjs
index 543e353..c074923 100644
--- a/lib/nodejs/test/test-cases.mjs
+++ b/lib/nodejs/test/test-cases.mjs
@@ -21,6 +21,7 @@
 
 import helpers from "./helpers.js";
 import Int64 from "node-int64";
+import { v4 as uuidv4, v7 as uuidv7 } from "uuid";
 
 const ttypes = await helpers.importTypes(`ThriftTest_types`);
 
@@ -97,6 +98,9 @@
     new Int64(new Buffer([0xff, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff])),
   ], // -2^53-1
   ["testTypedef", 69],
+  ["testUuid", "00112233-4455-6677-8899-aabbccddeeff"],
+  ["testUuid", uuidv4()],
+  ["testUuid", uuidv7()],
 ];
 
 const mapout = {};
diff --git a/lib/nodejs/test/testAll.sh b/lib/nodejs/test/testAll.sh
index a3baa6e..1823a8c 100755
--- a/lib/nodejs/test/testAll.sh
+++ b/lib/nodejs/test/testAll.sh
@@ -85,17 +85,17 @@
 
 # generating Thrift code
 
-${THRIFT_COMPILER} -o ${DIR} --gen js:node ${THRIFT_FILES_DIR}/v0.16/ThriftTest.thrift
+${THRIFT_COMPILER} -o ${DIR} --gen js:node ${THRIFT_FILES_DIR}/ThriftTest.thrift
 ${THRIFT_COMPILER} -o ${DIR} --gen js:node ${THRIFT_FILES_DIR}/JsDeepConstructorTest.thrift
 ${THRIFT_COMPILER} -o ${DIR} --gen js:node ${THRIFT_FILES_DIR}/Int64Test.thrift
 ${THRIFT_COMPILER} -o ${DIR} --gen js:node ${THRIFT_FILES_DIR}/Include.thrift
 mkdir ${DIR}/gen-nodejs-es6
-${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${THRIFT_FILES_DIR}/v0.16/ThriftTest.thrift
+${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${THRIFT_FILES_DIR}/ThriftTest.thrift
 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${THRIFT_FILES_DIR}/JsDeepConstructorTest.thrift
 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${THRIFT_FILES_DIR}/Int64Test.thrift
 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-es6 --gen js:node,es6 ${THRIFT_FILES_DIR}/Include.thrift
 mkdir ${DIR}/gen-nodejs-esm
-${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-esm --gen js:node,es6,esm ${THRIFT_FILES_DIR}/v0.16/ThriftTest.thrift
+${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-esm --gen js:node,es6,esm ${THRIFT_FILES_DIR}/ThriftTest.thrift
 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-esm --gen js:node,es6,esm ${THRIFT_FILES_DIR}/JsDeepConstructorTest.thrift
 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-esm --gen js:node,es6,esm ${THRIFT_FILES_DIR}/Int64Test.thrift
 ${THRIFT_COMPILER} -out ${DIR}/gen-nodejs-esm --gen js:node,es6,esm ${THRIFT_FILES_DIR}/Include.thrift
diff --git a/lib/nodejs/test/test_handler.mjs b/lib/nodejs/test/test_handler.mjs
index a378fe1..e6a2af2 100644
--- a/lib/nodejs/test/test_handler.mjs
+++ b/lib/nodejs/test/test_handler.mjs
@@ -64,6 +64,7 @@
   "testI64",
   "testDouble",
   "testBinary",
+  "testUuid",
   "testStruct",
   "testNest",
   "testMap",
diff --git a/lib/nodets/Makefile.am b/lib/nodets/Makefile.am
index ac2aa6e..de523f5 100644
--- a/lib/nodets/Makefile.am
+++ b/lib/nodets/Makefile.am
@@ -17,9 +17,9 @@
 
 # We call npm twice to work around npm issues
 
-stubs: $(top_srcdir)/test/v0.16/ThriftTest.thrift
+stubs: $(top_srcdir)/test/ThriftTest.thrift
 	mkdir -p test-compiled
-	$(THRIFT) --gen js:node,ts -o test/ $(top_srcdir)/test/v0.16/ThriftTest.thrift && $(THRIFT) --gen js:node,ts -o test-compiled $(top_srcdir)/test/v0.16/ThriftTest.thrift
+	$(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
 	$(THRIFT) --gen js:node,ts -o test/ $(top_srcdir)/test/Int64Test.thrift && $(THRIFT) --gen js:node,ts -o test-compiled $(top_srcdir)/test/Int64Test.thrift
 
 ts-compile: stubs
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,