@sv-tools/protoc-gen-ts-pblite

0.1.0-alpha.4 • Public • Published

protoc-gen-ts-pblite

Compile .proto files to simple, dependency-free TypeScript classes, for use with Google's PBLite format.

  • Messages become typescript classes.
  • Enums become typescript enums.
  • Fields become getters/setter properties.
  • The output does not have a dependency on google-protobuf.

PBLite is the format used for storage by google-protobuf and for data transfer by some Google GRPC services. It encodes protobuf messages as nested JSON arrays.

Options

--ts-pblite_opt=generic (default)

Generate serialize() methods using the google-protobuf API.

--ts-pblite_opt=url

Generate standalone stringify${MessageName} functions that serialize to Google's PBLite URL string format.

import { stringifyTilePanoramasRequest, TilePanoramasRequest } from './protos'
declare const request: TilePanoramasRequest
const pb: string = stringifyTilePanoramasRequest(request)
const query = new URLSearchParams(['pb', pb])
// Use in a URL

Using the URL format requires installing this base64 package to handle bytes fields:

npm install @jsonjoy.com/base64@^1.0.0

License

MIT · ⓒ 2022 Renée Kooi

Readme

Keywords

none

Package Sidebar

Install

npm i @sv-tools/protoc-gen-ts-pblite

Weekly Downloads

4

Version

0.1.0-alpha.4

License

MIT OR Apache-2.0

Unpacked Size

207 kB

Total Files

7

Last publish

Collaborators

  • goto-bus-stop