A mono-repo for a session type API code generation toolchain for modern web programming.
This project was originally built for Anson Miu's undergraduate Master's thesis at Imperial College London.
It was forked and extended for Neil Sayers' Master's thesis at Imperial College London.
nuscrcontains 𝝼Scr, for handling multiparty protocol descriptions, a dependency of our toolchain.codegencontains the source code of our code generator, written in Python, which generates TypeScript code for implementing the provided multiparty protocol.protocolscontains various Scribble protocol descriptions, including those used in the case studies.case-studiescontains 5 case studies of implementing interactive web applications with our toolchain, namely Noughts and Crosses, Travel Agency, Battleships, Online Wallet, Codenames.web-sandboxcontains configuration files for the web development, e.g. TypeScript configurations and NPMpackage.jsonfiles.
Refer to the helptext for detailed information:
$ python -m codegen --helpWe illustrate how to use our toolchain to generate TypeScript APIs:
The following command reads as follows:
$ python -m codegen protocols/TravelAgency.scr TravelAgency S \
node -o case-studies/TravelAgency/src-
Generate APIs for role
Sof theTravelAgencyprotocol specified inprotocols/TravelAgency.scr; -
Role
Sis implemented as anode(server-side) endpoint; -
Output the generated APIs under the path
case-studies/TravelAgency/src
The following command reads as follows:
$ python -m codegen protocols/TravelAgency.scr TravelAgency A \
browser -s S -o case-studies/TravelAgency/client/src-
Generate APIs for role
Aof theTravelAgencyprotocol specified inprotocols/TravelAgency.scr; -
Role
Ais implemented as abrowserendpoint, and assume roleSto be the server; -
Output the generated APIs under the path
case-studies/TravelAgency/client/src
To run the end-to-end tests:
$ cd web-sandbox/node
$ npm i
$ cd ../browser
$ npm i
$ cd ../..
$ python -m codegen.tests.systemThe end-to-end tests verify that
- The toolchain correctly parses the Scribble protocol specification files, and,
- The toolchain correctly generates TypeScript APIs, and,
- The generated APIs can be type-checked by the TypeScript Compiler successfully.
The protocol specification files, describing the multiparty communication, are located in the protocols folder.
The generated APIs are saved under web-sandbox (which is a sandbox environment set up for the TypeScript Compiler) and are deleted when the test finishes.
We include five case studies of realistic web applications implemented using the generated APIs.
For example, to generate the APIs for the case study OnlineWallet:
$ cd case-studies/OnlineWallet
$ npm i
$ cd client
$ npm i
$ cd ..
$ npm run build
$ npm startand visit http://localhost:8080.
Consult the wiki for more documentation.