Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package deltachat-rpc-server to npm #4694

Closed
link2xt opened this issue Sep 8, 2023 · 3 comments · Fixed by #5332
Closed

Package deltachat-rpc-server to npm #4694

link2xt opened this issue Sep 8, 2023 · 3 comments · Fixed by #5332
Assignees
Labels
enhancement New feature or request jsonrpc

Comments

@link2xt
Copy link
Collaborator

link2xt commented Sep 8, 2023

Currently there are 3 ways to use JSON-RPC bindings from JavaScript:

  1. Use legacy node bindings https://github.com/deltachat/deltachat-core-rust/tree/4a0585404a0a5f2e3edb4257a69d63efeb199ef3/node with CFFI calls to submit JSON-RPC requests and receive responses. This is what Delta Chat desktop is currently doing.
  2. Experimental napi-jsonrpc at https://github.com/deltachat/napi-jsonrpc/, currently not maintained and archived, stuck at v1.115.0, unlikely to be supported in the future.
  3. Spawn a deltachat-rpc-server process and use StdioTransport to communicate with it without any binary API.

Eventually we would like to deprecate first approach and switch to the third approach. The disadvantage of using the stdio approach currently is that the core distributed in the form of deltachat-rpc-server cannot be automatically installed as a dependency with npm install.

To close this issue we need to package deltachat-rpc-server to npm, so a single package can be installed that provide an API to spawn bundled deltachat-rpc-server for the host architecture and provide a JSON-RPC client that can be used.

This issue is split out of more general #4524.

@link2xt
Copy link
Collaborator Author

link2xt commented Sep 8, 2023

cc @ralphtheninja @Simon-Laux

@link2xt link2xt added enhancement New feature or request jsonrpc labels Sep 8, 2023
@adbenitez
Copy link
Member

adbenitez commented Oct 16, 2023

do we have a deltachat-rpc-client equivalent for JavaScript? IIRC the bindings are generated automatically for javascript and that is what DC desktop uses? something similar to deltachat-rpc-server but not over standard IO but web socket or so?

@Simon-Laux
Copy link
Member

Simon-Laux commented Oct 16, 2023

no desktop uses it over deltachat-node, then uses the bindings. the bindings don't care how you run or communicate with core, you just implement an interface for doing so and then you're ready to use the bindings: https://www.npmjs.com/package/@deltachat/jsonrpc-client

@Simon-Laux Simon-Laux self-assigned this Apr 16, 2024
Simon-Laux added a commit that referenced this issue May 11, 2024
- [x] figgure out how to build the packages (that it installs native
optional package automatically)
- [X] Make the gluecode
- [x] expose both the lowerlevel api that desktop uses (~~send objects
and receive objects~~, getting path of rpc-server is enough)
  - [X] and the higher level api needed for bots (jsonrpc client)
  - [X] typescript types
- [x] automatically pick the right binary from npm or allow getting it
from env var, or give out an error (throw error)
- [x] find out how to dev locally (use local built core in dc desktop) -
there is the question of how to link the typescript client and the task
to add a search in the cargo target folder for a debug build or a
different way, find out some good flow that we can use and document for
dc desktop + locally built core development
- [x] build the packages in ci
- [x] fix that deltachat-rpc-server is not executable

postponed:
- [ ] publish from ci
   - [ ] add key/token to deploy to npm 

Closes #4694

## Related prs
- deltachat-bot/echo#69
- deltachat/deltachat-desktop#3567

---------

Co-authored-by: link2xt <link2xt@testrun.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jsonrpc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants