Fix generation of episodic nodejs for services
- Extending services from the episode must also take the episodes into account
- Remove the reference in the generated ts for imported types since it can't be relative
- Extend the tests
diff --git a/lib/nodejs/test/episodic-code-generation-test/server.js b/lib/nodejs/test/episodic-code-generation-test/server.js
index 2b9a96d..5af48d9 100644
--- a/lib/nodejs/test/episodic-code-generation-test/server.js
+++ b/lib/nodejs/test/episodic-code-generation-test/server.js
@@ -24,14 +24,26 @@
program
.option("--port <port>", "Set the thrift server port", 9090)
+ .option("--base <base>", "Set the base: 'pure', 'base' or 'extend'", "pure")
.parse(process.argv);
-const Service = require("./gen-2/second-episode/gen-nodejs/Service");
+const ServiceBase = require("types-package/first-episode/BaseService");
+const ServicePure = require("./gen-2/second-episode/gen-nodejs/Service");
+const ServiceExtended = require("./gen-2/second-episode/gen-nodejs/ExtendedService");
const Types = require("types-package/first-episode/Types_types");
const opts = program.opts();
const port = opts.port;
+let Service;
+if (opts.base === "pure") {
+ Service = ServicePure;
+} else if (opts.base === "base") {
+ Service = ServiceBase;
+} else if (opts.base === "extend") {
+ Service = ServiceExtended;
+}
+
const options = {
transport: thrift.TBufferedTransport,
protocol: thrift.TJSONProtocol,
@@ -45,6 +57,13 @@
receivedType1Object.message + " [Hello from the server]";
return type1Object;
},
+ testEpisodeExtend: function (receivedType1Object) {
+ const type1Object = new Types.Type1();
+ type1Object.number = receivedType1Object.number + 1;
+ type1Object.message =
+ receivedType1Object.message + " [Hello from the extended server]";
+ return type1Object;
+ },
};
const server = thrift.createServer(Service, ServiceHandler, options);