tools icon indicating copy to clipboard operation
tools copied to clipboard

feat(node-api): create a node.js wrapper library for the JSON-RPC workspace protocol

Open leops opened this issue 3 years ago • 3 comments

Summary

This PR creates a new @rometools/backend-jsonrpc library that implements the Workspace API by wrapping the JSON-RPC protocol exposed by the daemon server. The library is split into a few modules that may be imported independently:

  • command resolves a file system path to the Rome binary
  • socket ensures the daemon process is spawned and opens a node.js Socket connection to the RPC channel
  • transport wraps an open socket and implements the JSON-RPC protocol as untyped method calls and responses
  • workspace is automatically generated from the JSON schema of the Workspace API, and wraps a Transport instance with an object implementing typed methods calls to the remote workspace

At the top level of the library a single createWorkspace method calls each of these in sequence, wrapping each layer with the next one and returning a Workspace object ready to use

Test Plan

I added a small test script that creates creates a workspace instance (using a local build of the binary from the Cargo target directory), executes a few method calls then shuts down

leops avatar Aug 16 '22 16:08 leops

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1633ef9
Status: ✅  Deploy successful!
Preview URL: https://3ffddac4.tools-8rn.pages.dev
Branch Preview URL: https://feature-node-api-jsonrpc.tools-8rn.pages.dev

View logs

Parser conformance results on ubuntu-latest

js/262

Test result main count This PR count Difference
Total 45878 45878 0
Passed 44938 44938 0
Failed 940 940 0
Panics 0 0 0
Coverage 97.95% 97.95% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 39 39 0
Passed 36 36 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.31% 92.31% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 5946 5946 0
Passed 396 396 0
Failed 5550 5550 0
Panics 0 0 0
Coverage 6.66% 6.66% 0.00%

ts/babel

Test result main count This PR count Difference
Total 588 588 0
Passed 519 519 0
Failed 69 69 0
Panics 0 0 0
Coverage 88.27% 88.27% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 16257 16257 0
Passed 12397 12397 0
Failed 3860 3860 0
Panics 0 0 0
Coverage 76.26% 76.26% 0.00%

github-actions[bot] avatar Aug 16 '22 16:08 github-actions[bot]