{"id":50832066,"url":"https://github.com/varavelio/vdl-plugin-rpc-ts","last_synced_at":"2026-06-14T00:05:07.573Z","repository":{"id":348547404,"uuid":"1196698646","full_name":"varavelio/vdl-plugin-rpc-ts","owner":"varavelio","description":"Plugin to generate VDL RPC for TypeScript","archived":false,"fork":false,"pushed_at":"2026-04-01T15:31:03.000Z","size":190,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-01T20:32:23.612Z","etag":null,"topics":["api","codegen","rpc","ts","typescript","varavel","vdl","vdl-plugin","vdl-rpc"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/varavelio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-03-31T00:35:43.000Z","updated_at":"2026-04-01T15:31:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/varavelio/vdl-plugin-rpc-ts","commit_stats":null,"previous_names":["varavelio/vdl-plugin-rpc-ts"],"tags_count":null,"template":false,"template_full_name":"varavelio/vdl-plugin-template","purl":"pkg:github/varavelio/vdl-plugin-rpc-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varavelio%2Fvdl-plugin-rpc-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varavelio%2Fvdl-plugin-rpc-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varavelio%2Fvdl-plugin-rpc-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varavelio%2Fvdl-plugin-rpc-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/varavelio","download_url":"https://codeload.github.com/varavelio/vdl-plugin-rpc-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varavelio%2Fvdl-plugin-rpc-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34304633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","codegen","rpc","ts","typescript","varavel","vdl","vdl-plugin","vdl-rpc"],"created_at":"2026-06-14T00:05:06.867Z","updated_at":"2026-06-14T00:05:07.563Z","avatar_url":"https://github.com/varavelio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg\n    src=\"https://raw.githubusercontent.com/varavelio/vdl/9cb8432f972f986ba91ffa1e4fe82220a8aa373f/assets/png/vdl.png\"\n    alt=\"VDL logo\"\n    width=\"130\"\n  /\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eVDL RPC TypeScript Plugin\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  Generate TypeScript \u003cstrong\u003eRPC clients\u003c/strong\u003e and \u003cstrong\u003eRPC servers\u003c/strong\u003e from annotation-based VDL services.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://varavel.com\"\u003e\n    \u003cimg src=\"https://cdn.jsdelivr.net/gh/varavelio/brand@1.0.0/dist/badges/project.svg\" alt=\"A Varavel project\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://varavel.com/vdl\"\u003e\n    \u003cimg src=\"https://cdn.jsdelivr.net/gh/varavelio/brand@1.0.0/dist/badges/vdl-plugin.svg\" alt=\"VDL Plugin\"/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nThis plugin is RPC-only.\n\nIt does not generate business types, enums, or constants. Those come from [`varavelio/vdl-plugin-ts`](https://github.com/varavelio/vdl-plugin-ts), and this plugin references them through `typesImport`.\n\nAll examples below use `varavelio/vdl-plugin-rpc-ts@v0.1.0`.\n\n## Quick Start\n\n1. Generate TypeScript models with `varavelio/vdl-plugin-ts`.\n2. Generate RPC client (`target \"client\"`) and/or RPC server (`target \"server\"`).\n3. Run your normal VDL generation command (for example: `vdl generate`).\n\n```vdl\nconst config = {\n  version 1\n  plugins [\n    {\n      src \"varavelio/vdl-plugin-ts@v0.1.4\"\n      schema \"./schema.vdl\"\n      outDir \"./generated/types\"\n      options {\n        importExtension \"js\"\n      }\n    }\n    {\n      src \"varavelio/vdl-plugin-rpc-ts@v0.1.0\"\n      schema \"./schema.vdl\"\n      outDir \"./generated/client\"\n      options {\n        target \"client\"\n        typesImport \"../types/index.js\"\n        importExtension \"js\"\n      }\n    }\n    {\n      src \"varavelio/vdl-plugin-rpc-ts@v0.1.0\"\n      schema \"./schema.vdl\"\n      outDir \"./generated/server\"\n      options {\n        target \"server\"\n        typesImport \"../types/index.js\"\n        importExtension \"js\"\n      }\n    }\n  ]\n}\n```\n\nIf you only need one side, keep only one RPC plugin block.\n\n## Plugin Options\n\n| Option            | Type                     | Required | Default | What it changes                                                                                       |\n| ----------------- | ------------------------ | -------- | ------- | ----------------------------------------------------------------------------------------------------- |\n| `typesImport`     | `string`                 | yes      | -       | Import path pointing to the output generated by `varavelio/vdl-plugin-ts` (used exactly as provided). |\n| `target`          | `\"client\" \\| \"server\"`   | yes      | -       | Selects what to generate in that invocation. The plugin generates one target at a time.               |\n| `importExtension` | `\"none\" \\| \"js\" \\| \"ts\"` | no       | `\"js\"`  | Controls internal imports between generated RPC files. It does not rewrite `typesImport`.             |\n\n## Generated Files\n\nFor `target \"client\"`:\n\n- `client.ts`\n\nFor `target \"server\"`:\n\n- `server.ts`\n- `adapters/node.ts`\n- `adapters/fetch.ts`\n\nIf your schema has no discovered `@rpc`, `@proc` or `@stream` operations, no files are emitted.\n\n## What You Get\n\nFor `target \"client\"`:\n\n- `NewClient(baseURL).build()` to create a typed client.\n- Flattened procedure and stream builders under `client.procs.*()` and `client.streams.*()`.\n- Global and operation-level headers (static or dynamic providers).\n- Interceptors.\n- Retry/timeout for procedures and reconnect policies for streams.\n- Stream lifecycle hooks and maximum message size controls.\n\nFor `target \"server\"`:\n\n- `new Server\u003cProps\u003e()` with typed request context.\n- Typed registration APIs for procedures and streams.\n- Middleware at global, RPC, procedure, stream, and stream-emit levels.\n- Global and RPC-level error handlers.\n- Global, RPC-level, and stream-level ping configuration.\n- `createNodeHandler(...)` and `createFetchHandler(...)` adapters for HTTP runtimes.\n\nBoth targets include runtime catalogs:\n\n- `VDLPaths`\n- `VDLProcedures`\n- `VDLStreams`\n\nNon-marker annotations are preserved in operation metadata.\n\n## RPC Annotation Model\n\nThis plugin follows the VDL annotation model:\n\n- `@rpc` marks a top-level type as an RPC service.\n- `@proc` marks a field as a request-response operation.\n- `@stream` marks a field as a server-streaming operation.\n\n```vdl\n@rpc\ntype Messages {\n  @proc\n  send {\n    input {\n      roomId string\n      text string\n    }\n\n    output {\n      accepted bool\n    }\n  }\n\n  @stream\n  events {\n    input {\n      roomId string\n    }\n\n    output {\n      text string\n    }\n  }\n}\n```\n\n## Usage Example\n\n### Client\n\n```ts\nimport { NewClient } from \"./generated/client/client\";\n\nconst client = NewClient(\"http://localhost:3000/rpc\")\n  .withGlobalHeader(\"authorization\", \"Bearer \u003ctoken\u003e\")\n  .build();\n\nconst procOutput = await client.procs.messagesSend().execute({\n  roomId: \"room-1\",\n  text: \"hello\",\n});\n\nconsole.log(procOutput.accepted);\n\nconst { stream, cancel } = client.streams.messagesEvents().execute({\n  roomId: \"room-1\",\n});\n\nfor await (const event of stream) {\n  if (!event.ok) {\n    console.error(event.error);\n    break;\n  }\n\n  console.log(event.output.text);\n}\n\ncancel();\n```\n\n### Server (Node.js adapter)\n\n```ts\nimport { createServer } from \"node:http\";\nimport { Server } from \"./generated/server/server\";\nimport { createNodeHandler } from \"./generated/server/adapters/node\";\n\ntype Context = { requestId: string };\n\nconst rpcServer = new Server\u003cContext\u003e();\n\nrpcServer.rpcs\n  .messages()\n  .procs.send()\n  .handle(async (_ctx) =\u003e {\n    return { accepted: true };\n  });\n\nrpcServer.rpcs\n  .messages()\n  .streams.events()\n  .handle(async (ctx, emit) =\u003e {\n    await emit(ctx, { text: `joined ${ctx.input.roomId}` });\n  });\n\nconst handler = createNodeHandler(rpcServer, () =\u003e ({ requestId: \"req-1\" }), {\n  prefix: \"/rpc\",\n});\n\ncreateServer(async (req, res) =\u003e {\n  await handler(req, res);\n}).listen(3000);\n```\n\n### Server (Fetch-compatible adapter)\n\n```ts\nimport { Server } from \"./generated/server/server\";\nimport { createFetchHandler } from \"./generated/server/adapters/fetch\";\n\nconst rpcServer = new Server();\n\nexport default {\n  fetch: createFetchHandler(rpcServer, undefined, { prefix: \"/rpc\" }),\n};\n```\n\n## Important Notes\n\n- `baseURL` in `NewClient(baseURL)` should point to your RPC prefix (for example: `https://api.example.com/rpc`).\n- The generated client appends `/{rpcName}/{operationName}` automatically.\n- `typesImport` must point to the generated output from `vdl-plugin-ts`.\n- To generate both client and server, run this plugin twice (one block per `target`).\n\n## License\n\nThis plugin is released under the MIT License. See [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaravelio%2Fvdl-plugin-rpc-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaravelio%2Fvdl-plugin-rpc-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaravelio%2Fvdl-plugin-rpc-ts/lists"}