{"_id":"@apachedubbo/protoc-gen-apache-dubbo-es","name":"@apachedubbo/protoc-gen-apache-dubbo-es","dist-tags":{"alpha":"3.0.0-alpha","latest":"3.0.0-alpha"},"versions":{"3.0.0-alpha":{"name":"@apachedubbo/protoc-gen-apache-dubbo-es","version":"3.0.0-alpha","description":"Code generator for Dubbo","license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/apache/dubbo-js.git","directory":"packages/protoc-gen-apache-dubbo-es"},"bin":{"protoc-gen-apache-dubbo-es":"bin/protoc-gen-apache-dubbo-es"},"engines":{"node":">=16.0.0"},"scripts":{"clean":"rm -rf ./dist/cjs/*","build":"tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs"},"preferUnplugged":true,"dependencies":{"@bufbuild/protobuf":"^1.2.1","@bufbuild/protoplugin":"^1.2.1"},"peerDependencies":{"@apachedubbo/dubbo":"3.0.0-alpha","@bufbuild/protoc-gen-es":"^1.2.1"},"peerDependenciesMeta":{"@apachedubbo/dubbo":{"optional":true},"@bufbuild/protoc-gen-es":{"optional":true}},"gitHead":"dd9eba1b7b4c5d306fc8275537694cca02ad7975","bugs":{"url":"https://github.com/apache/dubbo-js/issues"},"homepage":"https://github.com/apache/dubbo-js#readme","_id":"@apachedubbo/protoc-gen-apache-dubbo-es@3.0.0-alpha","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-U6iOYl0HWVe9eXA3T+OsPx161xuDtXanKr9DNB0a+PFzUeC7Xdeyuq3xZkfYB14697xK7fZXHBxwOcCA4boyTw==","shasum":"1b43c7f30593ba452a4866ccf0a2a0e00a41b263","tarball":"https://registry.npmjs.org/@apachedubbo/protoc-gen-apache-dubbo-es/-/protoc-gen-apache-dubbo-es-3.0.0-alpha.tgz","fileCount":8,"unpackedSize":18154,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH10R1Q41jSTExOZ31b7EU1YEhcVtire1pmJpO5CWFUwAiAOsBwCOUfM9pWsFFBY3fgsSaWwhVuE7WiNM+P/42fpZA=="}]},"_npmUser":{"name":"jianyi-gronk","email":"jianyi_gronk@163.com"},"directories":{},"maintainers":[{"name":"jianyi-gronk","email":"jianyi_gronk@163.com"},{"name":"apache-dubbo","email":"dubbo.alibaba@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/protoc-gen-apache-dubbo-es_3.0.0-alpha_1694061679870_0.40634347060173504"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-07T04:41:19.777Z","3.0.0-alpha":"2023-09-07T04:41:20.112Z","modified":"2023-09-07T04:41:20.422Z"},"maintainers":[{"name":"jianyi-gronk","email":"jianyi_gronk@163.com"},{"name":"apache-dubbo","email":"dubbo.alibaba@gmail.com"}],"description":"Code generator for Dubbo","homepage":"https://github.com/apache/dubbo-js#readme","repository":{"type":"git","url":"git+https://github.com/apache/dubbo-js.git","directory":"packages/protoc-gen-apache-dubbo-es"},"bugs":{"url":"https://github.com/apache/dubbo-js/issues"},"license":"Apache-2.0","readme":"# @apachedubbo/protoc-gen-apache-dubbo-es\n\nThe code generator for Dubbo, a simple library to work with servers and clients\nin ECMAScript with the type-safety of TypeScript. It generates code that is compatible with\nbrowsers and Node.js.\n\nLearn more about Dubbo at [github.com/apache/dubbo-js](https://github.com/apache/dubbo-js).\n\n## Installation\n\n`@apachedubbo/protoc-gen-apache-dubbo-es` is a code generator plugin for Protocol Buffer compilers,\nlike [buf](https://github.com/bufbuild/buf) and [protoc](https://github.com/protocolbuffers/protobuf/releases).\nIt generates clients as well as server definitions from your Protocol Buffer schema, and works in tandem with\n[@bufbuild/protoc-gen-es](https://www.npmjs.com/package/@bufbuild/protoc-gen-es),\nthe code generator plugin for all Protocol Buffer base types. The code these two\nplugins generate requires the runtime libraries [@apachedubbo/dubbo](https://www.npmjs.com/package/@apachedubbo/dubbo),\nand [@bufbuild/protobuf](https://www.npmjs.com/package/@bufbuild/protobuf).\n\nTo install `buf`, the plugins and their runtime libraries, run:\n\n```shell\nnpm install --save-dev @bufbuild/buf @bufbuild/protoc-gen-es @apachedubbo/protoc-gen-apache-dubbo-es\nnpm install @apachedubbo/dubbo @bufbuild/protobuf\n```\n\nIf you want to call Dubbo or gRPC-web services from a web browsers, make sure to install\n[@apachedubbo/dubbo-web](https://www.npmjs.com/package/@apachedubbo/dubbo-web). If you want servers too,\ninstall [@apachedubbo/dubbo-node](https://www.npmjs.com/package/@apachedubbo/dubbo-node),\n[@apachedubbo/dubbo-fastify](https://www.npmjs.com/package/@apachedubbo/dubbo-fastify), or\n[@apachedubbo/dubbo-express](https://www.npmjs.com/package/@apachedubbo/dubbo-express)\n\nWe use peer dependencies to ensure that code generator and runtime library are\ncompatible with each other. Note that npm installs them automatically, but yarn\nand pnpm do not.\n\n## Generating code\n\n### With buf\n\nAdd a new configuration file `buf.gen.yaml`:\n\n```yaml\n# buf.gen.yaml defines a local generation template.\n# For details, see https://docs.buf.build/configuration/v1/buf-gen-yaml\nversion: v1\nplugins:\n  # This will invoke protoc-gen-es and write output to src/gen\n  - plugin: es\n    out: src/gen\n    opt: target=ts\n  # This will invoke @apachedubbo/protoc-gen-apache-dubbo-es\n  - plugin: apache-dubbo-es\n    out: src/gen\n    opt:\n      # Add more plugin options here\n      - target=ts\n```\n\nTo generate code for all protobuf files within your project, simply run:\n\n```bash\nnpx buf generate\n```\n\nNote that `buf` can generate from various [inputs](https://docs.buf.build/reference/inputs),\nnot just local protobuf files. For example, `npx buf generate buf.build/bufbuild/eliza`\ngenerates code for the module [bufbuild/eliza](https://buf.build/bufbuild/eliza) on the Buf Schema\nRegistry.\n\n### With protoc\n\n```bash\nPATH=$PATH:$(pwd)/node_modules/.bin \\\n  protoc -I . \\\n  --es_out src/gen \\\n  --es_opt target=ts \\\n  --connect-es_out src/gen \\\n  --connect-es_opt target=ts \\\n  a.proto b.proto c.proto\n```\n\nNote that we are adding `node_modules/.bin` to the `$PATH`, so that the protocol\nbuffer compiler can find them. This happens automatically with npm scripts.\n\nSince yarn v2 and above does not use a `node_modules` directory, you need to\nchange the variable a bit:\n\n```bash\nPATH=$(dirname $(yarn bin protoc-gen-es)):$(dirname $(yarn bin @apachedubbo/protoc-gen-apache-dubbo-es)):$PATH\n```\n\n## Plugin options\n\n### `target`\n\nThis option controls whether the plugin generates JavaScript, TypeScript,\nor TypeScript declaration files.\n\nPossible values:\n\n- `target=js` - generates a `_dubbo.js` file for every `.proto` input file.\n- `target=ts` - generates a `_dubbo.ts` file for every `.proto` input file.\n- `target=dts` - generates a `_dubbo.d.ts` file for every `.proto` input file.\n\nMultiple values can be given by separating them with `+`, for example\n`target=js+dts`.\n\nBy default, we generate JavaScript and TypeScript declaration files, which\nproduces the smallest code size and is the most compatible with various\nbundler configurations. If you prefer to generate TypeScript, use `target=ts`.\n\n### `import_extension=.js`\n\nBy default, [@apachedubbo/protoc-gen-apache-dubbo-es](https://www.npmjs.com/package/@apachedubbo/protoc-gen-apache-dubbo-es)\n(and all other plugins based on [@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin))\nuses a `.js` file extensions in import paths, even in TypeScript files.\n\nThis is unintuitive, but necessary for [ECMAScript modules in Node.js](https://www.typescriptlang.org/docs/handbook/esm-node.html).\nUnfortunately, not all bundlers and tools have caught up yet, and Deno\nrequires `.ts`. With this plugin option, you can replace `.js` extensions\nin import paths with the given value. For example, set\n\n- `import_extension=none` to remove the `.js` extension\n- `import_extension=.ts` to replace the `.js` extension with `.ts`\n\n### `keep_empty_files=true`\n\nBy default, [@apachedubbo/protoc-gen-apache-dubbo-es](https://www.npmjs.com/package/@apachedubbo/protoc-gen-apache-dubbo-es)\n(and all other plugins based on [@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin))\nomit empty files from the plugin output. This option disables pruning of\nempty files, to allow for smooth interoperation with Bazel and similar\ntooling that requires all output files to be declared ahead of time.\nUnless you use Bazel, it is very unlikely that you need this option.\n\n## Example generated code\n\n`eliza.proto`\n\n```protobuf\nsyntax = \"proto3\";\n\npackage buf.connect.demo.eliza.v1;\n\n// ElizaService provides a way to talk to the ELIZA, which is a port of\n// the DOCTOR script for Joseph Weizenbaum's original ELIZA program.\n// Created in the mid-1960s at the MIT Artificial Intelligence Laboratory,\n// ELIZA demonstrates the superficiality of human-computer communication.\n// DOCTOR simulates a psychotherapist, and is commonly found as an Easter\n// egg in emacs distributions.\nservice ElizaService {\n  // Say is a unary request demo. This method should allow for a one sentence\n  // response given a one sentence request.\n  rpc Say(SayRequest) returns (SayResponse) {}\n}\n\n// SayRequest describes the sentence said to the ELIZA program.\nmessage SayRequest {\n  string sentence = 1;\n}\n\n// SayResponse describes the sentence responded by the ELIZA program.\nmessage SayResponse {\n  string sentence = 1;\n}\n```\n\n`eliza_dubbo.ts`\n\n```ts\n/**\n * ElizaService provides a way to talk to the ELIZA, which is a port of\n * the DOCTOR script for Joseph Weizenbaum's original ELIZA program.\n * Created in the mid-1960s at the MIT Artificial Intelligence Laboratory,\n * ELIZA demonstrates the superficiality of human-computer communication.\n * DOCTOR simulates a psychotherapist, and is commonly found as an Easter\n * egg in emacs distributions.\n *\n * @generated from service buf.connect.demo.eliza.v1.ElizaService\n */\nexport const ElizaService = {\n  typeName: 'buf.connect.demo.eliza.v1.ElizaService',\n  methods: {\n    /**\n     * Say is a unary request demo. This method should allow for a one sentence\n     * response given a one sentence request.\n     *\n     * @generated from rpc buf.connect.demo.eliza.v1.ElizaService.Say\n     */\n    say: {\n      name: 'Say',\n      I: SayRequest,\n      O: SayResponse,\n      kind: MethodKind.Unary\n    }\n  }\n} as const\n```\n","readmeFilename":"README.md"}