{"id":24092526,"url":"https://github.com/means88/tsbuf","last_synced_at":"2025-05-07T00:42:23.082Z","repository":{"id":33282924,"uuid":"154691328","full_name":"Means88/tsbuf","owner":"Means88","description":"Generate TypeScript enum and interface from proto buffer.","archived":false,"fork":false,"pushed_at":"2024-02-27T16:33:38.000Z","size":3444,"stargazers_count":11,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-01T20:13:45.312Z","etag":null,"topics":["parser","protobuf"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Means88.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-25T15:06:27.000Z","updated_at":"2023-05-08T08:15:25.000Z","dependencies_parsed_at":"2023-02-18T03:25:14.667Z","dependency_job_id":null,"html_url":"https://github.com/Means88/tsbuf","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Means88%2Ftsbuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Means88%2Ftsbuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Means88%2Ftsbuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Means88%2Ftsbuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Means88","download_url":"https://codeload.github.com/Means88/tsbuf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252793546,"owners_count":21805053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["parser","protobuf"],"created_at":"2025-01-10T07:45:17.859Z","updated_at":"2025-05-07T00:42:23.065Z","avatar_url":"https://github.com/Means88.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tsbuf  [![npm@version](https://img.shields.io/npm/v/tsbuf.svg)](https://www.npmjs.com/package/tsbuf) [![Build Status](https://travis-ci.org/Means88/tsbuf.svg?branch=master)](https://travis-ci.org/Means88/tsbuf) [![Coverage Status](https://coveralls.io/repos/github/Means88/tsbuf/badge.svg?branch=master)](https://coveralls.io/github/Means88/tsbuf?branch=master)\n\nGenerate TypeScript enum and interface with proto buffer.\n\n## Usage\n```bash\nnpm install -g tsbuf\ntsbuf example/proto -o example/typescript/global\n# or\ntsbuf example/proto -o example/typescript/module -m module\n\n```\nSee `example/`\n\n```console\n$ tsbuf -h\nUsage: tsbuf [options] \u003cinputPath\u003e\n\nprotobuf-parser\nGenerate TypeScript interface with Protobuf.\n\nOptions:\n  -V, --version          output the version number\n  -o, --output \u003coutput\u003e  output path (default: \".\")\n  -m, --mode \u003cmode\u003e      \"global\": Global Definition, \"module\": Module Definition (default: \"global\")\n  -h, --help             output usage information\n\n```\n\n## Example\n\n```proto\nsyntax = \"proto3\";\n\nservice MyService {\n  rpc rpcMethod(Fruit) returns (Package) {}\n}\n\nenum Fruit {\n  Apple = 0;\n  Banana = 1;\n}\n\nmessage Package {\n  string id = 1;\n  float price = 2;\n}\n\n```\nWill be transformed to\n\n```typescript\ninterface MyService {\n  rpcMethod: {\n    request: Request;\n    response: Response;\n  };\n}\n\ndeclare enum Fruit {\n  Apple = 0,\n  Banana = 1,\n}\n\ninterface Package {\n  id: string;\n  price: number;\n}\n```\nOr TypeScript module\n```typescript\nexport interface MyService {\n  rpcMethod: {\n    request: Request;\n    response: Response;\n  };\n}\n\nexport enum Fruit {\n  Apple = 0,\n  Banana = 1,\n}\n\nexport interface Package {\n  id: string;\n  price: number;\n}\n\n```\n\n### How to use interfaces from service?\n\nCreate specified types using TypeScript as follows.\n\n```typescript\nimport { MyService } from '...';\nimport { Observable } from 'rxjs';\n\ninterface BaseServiceDefinition {\n  [key: string]: {\n    request: any;\n    response: any;\n  };\n}\n\ntype RxService\u003cT extends BaseServiceDefinition\u003e = {\n  [K in keyof T]: (request: T[K]['request']) =\u003e Observable\u003cT[K]['response']\u003e;\n};\n\n/**\n * `RxService\u003cMyService\u003e` equals:\n *\n * interface {\n *   rpcMethod(request: Request): Observable\u003cResponse\u003e;\n * }\n *\n **/\n\n```\n\n## Roadmap\n\n- [x] Basic Support\n- [x] ExtendedType Field\n- [x] Cli\n- [x] Oneof Field\n- [x] Map Field\n- [x] Nested Type\n- [x] Generate Global Declaration\n- [x] Import (Generate Module)\n- [ ] Other Options\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeans88%2Ftsbuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeans88%2Ftsbuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeans88%2Ftsbuf/lists"}