Generate types and service clients from protobuf definitions annotated with http rules.

Related tags

typescript protobuf protoc
Overview

protoc-gen-typescript-http

Generates Typescript types and service clients from protobuf definitions annotated with http rules. The generated types follow the canonical JSON encoding.

Experimental: This library is under active development and breaking changes to config files, APIs and generated code are expected between releases.

Using the plugin

For examples of correctly annotated protobuf defintions and the generated code, look at examples.

Install the plugin

go get github.com/einride/protoc-gen-typescript-http

Or download a prebuilt binary from releases.

Invocation

protoc 
  --typescript-http_out [OUTPUT DIR] \
  [.proto files ...]

The generated clients can be used with any HTTP client that returns a Promise containing JSON data.

const rootUrl = "...";

type Request = {
  path: string,
  method: string,
  body: string | null
}

function fetchRequestHandler({path, method, body}: Request) {
  return fetch(rootUrl + path, {method, body}).then(response => response.json())
}

export function siteClient() {
  return createShipperServiceClient(fetchRequestHandler);
}
Issues
  • chore(deps): bump actions/setup-node from 2.2.0 to 2.3.2

    chore(deps): bump actions/setup-node from 2.2.0 to 2.3.2

    Bumps actions/setup-node from 2.2.0 to 2.3.2.

    Release notes

    Sourced from actions/setup-node's releases.

    Revert temporary fix

    We had to disable pre-cached Node.js usage in the previous version due to the broken image cache. Now cache is fixed, so we can safely enable its usage again. Thank you for understanding.

    Temporary maintenance fix.

    Temporarily disabled usage of pre-cached Node.js.

    Support caching pnpm dependencies

    This release introduces dependency caching support for the pnpm package manager (#278).

    Caching pnpm dependencies:

    # This workflow uses actions that are not certified by GitHub.
    # They are provided by a third-party and are governed by
    # separate terms of service, privacy policy, and support
    # documentation.
    

    steps:

NOTE: pnpm caching support requires pnpm version >= 6.10.0

Commits
  • 4d0182a Merge pull request #310 from actions/revert-308-v-alsvir/disable-cache-usage-...
  • 896ee80 Restore YARN flag
  • d21ecc7 Revert "Temporarily disabled cache usage for v2"
  • d6e3b55 Merge pull request #308 from actions/v-alsvir/disable-cache-usage-temp-v2
  • db716f8 Add yarn env variable
  • c24389f Staging unstaged
  • 004fb83 Temporarily disabled cache usage
  • aa759c6 Merge pull request #278 from jacobwgillespie/cache-pnpm
  • 0ae03de Reorder to npm, yarn, pnpm
  • 4bc87b8 Bump e2e tests to 6.10.0
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
dependencies github_actions 
opened by dependabot[bot] 1
  • chore(deps): bump actions/setup-node from 2.2.0 to 2.3.1

    chore(deps): bump actions/setup-node from 2.2.0 to 2.3.1

    Bumps actions/setup-node from 2.2.0 to 2.3.1.

    Release notes

    Sourced from actions/setup-node's releases.

    Temporary maintenance fix.

    Temporarily disabled usage of pre-cached Node.js.

    Support caching pnpm dependencies

    This release introduces dependency caching support for the pnpm package manager (#278).

    Caching pnpm dependencies:

    # This workflow uses actions that are not certified by GitHub.
    # They are provided by a third-party and are governed by
    # separate terms of service, privacy policy, and support
    # documentation.
    

    steps:

  • NOTE: pnpm caching support requires pnpm version >= 6.10.0

    Commits
    • d6e3b55 Merge pull request #308 from actions/v-alsvir/disable-cache-usage-temp-v2
    • db716f8 Add yarn env variable
    • c24389f Staging unstaged
    • 004fb83 Temporarily disabled cache usage
    • aa759c6 Merge pull request #278 from jacobwgillespie/cache-pnpm
    • 0ae03de Reorder to npm, yarn, pnpm
    • 4bc87b8 Bump e2e tests to 6.10.0
    • b96348a Remove unused imports
    • 3af302a Switch to pnpm store path command
    • f452812 Unmock fs.existsSync after tests
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 1
  • chore: add README

    chore: add README

    Last piece for being considered for open source.

    opened by ericwenn 1
  • chore(deps): bump actions/setup-node from 2.2.0 to 2.3.0

    chore(deps): bump actions/setup-node from 2.2.0 to 2.3.0

    Bumps actions/setup-node from 2.2.0 to 2.3.0.

    Release notes

    Sourced from actions/setup-node's releases.

    Support caching pnpm dependencies

    This release introduces dependency caching support for the pnpm package manager (#278).

    Caching pnpm dependencies:

    # This workflow uses actions that are not certified by GitHub.
    # They are provided by a third-party and are governed by
    # separate terms of service, privacy policy, and support
    # documentation.
    

    steps:

  • NOTE: pnpm caching support requires pnpm version >= 6.10.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    dependencies github_actions 
    opened by dependabot[bot] 1
  • chore(deps): bump google.golang.org/protobuf from 1.26.0 to 1.27.0

    chore(deps): bump google.golang.org/protobuf from 1.26.0 to 1.27.0

    Bumps google.golang.org/protobuf from 1.26.0 to 1.27.0.

    Release notes

    Sourced from google.golang.org/protobuf's releases.

    v1.27.0

    Overview

    The release provides new functionality for iterating through a message using protobuf reflection. There are some minor changes to the code generator.

    Notable changes

    New features:

    • CL/309669: testing/protopack: add Message.UnmarshalAbductive

    Bug fixes:

    • CL/317430: encoding/prototext: fix skipping of unknown fields
    • CL/321529: internal/impl: support typed nil source for Merge of aberrant messages

    Generator changes

    • CL/305574: cmd/protoc-gen-go: remove generation of the ExtensionRangeArray method
    • CL/319649: cmd/protoc-gen-go: avoid referencing remote enum values by name
    • CL/316949: compiler/protogen: relax rules for valid import paths
    • CL/306209: cmd/protoc-gen-go: add protoc suffix

    Reflectively ranging over a message

    • CL/236540: reflect: add protopath and protorange packages

    The new reflect/protorange package supports recursively ranging through all populated fields of a message. There are many use cases for such a feature. See the examples for inspiration.

    Upcoming breakage changes

    This release removes generation of the ExtensionRangeArray method, as originally announced since the v1.20.0 release on March 2nd, 2020. Our analysis of the entire public module proxy found no static usages of this method. This method is pseudo-internal to the implementation and we expect removal of it to have no material impact. If something is broken by this change, please file an issue and we can consider re-generating this method in a patch release.

    There are no new upcoming breaking changes to announce in this release.

    Commits
    • 3f51f05 all: release v1.27.0
    • dc57387 release.bash: make work on Linux
    • 21e33cc reflect/protoregistry: restore conflicting file names check
    • 426f20b release.bash: make work on macOS
    • febffdd reflect/protoregistry: permit conflicting file names
    • 4c193d1 compiler/protogen: relax rules for valid import paths
    • acaef6a cmd/protoc-gen-go: avoid referencing remote enum values by name
    • 50a8591 all: build Windows protoc-gen-go as a .exe in a zip
    • 24d799b internal/impl: support typed nil source for Merge of aberrant messages
    • 0e358a4 reflect/protorange: fix typo of func name in comment
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies go 
    opened by dependabot[bot] 1
  • fix!: use type union instead of optional for fields

    fix!: use type union instead of optional for fields

    Changes how nullability is expressed in the generated types.

    Previously every field was optional

    type Message = {
      field?: string;
    }
    

    which is convenient as there is no need to specify every field that exists in the message when declaring it.

    However this have some unfortunate side effects, most notably that almost every type is assignable to other types.

    type MessageA = {
      foo?: string;
    }
    
    type MessageB = {
      bar?: string;
    }
    
    const a: MessageA = {}
    const b: MessageB = a; // ok because no field needs to be set in
    MessageB.
    

    This can lead to subtle bugs when passing these types around.

    With this change every field is no longer optional, but undefined is a valid value for every field.

    type MessageA = {
      field: string | undefined;
    }
    

    Fields belonging to a oneof is still typed as optional, because only one of these fields should ever be set.

    type MessageA = {
      foo: string | undefined;
    }
    
    type MessageB = {
      bar: string | undefined;
    }
    
    const a: MessageA = { foo: undefined };
    const b: MessageB = a; // error
    

    BREAKING CHANGE: Fields that could previously be omitted when declaring a variable, now needs to explicitly be set to undefined. Code that reads these fields will not break.

    opened by ericwenn 1
  • feat: initial implementation of protoc-gen-typescript-http

    feat: initial implementation of protoc-gen-typescript-http

    Generates types and service clients from protobuf definitions annotated with http rules. See examples for output.

    Notes:

    • Every package is generated into a single index.ts file. This makes imports (both within the generated code and external callers) simpler.
    • Every dependency of a package is inlined in the same index.ts file. There are no public repositories for well known types (Duration, Timestamp etc) in Typesript. In practice there will not be many external dependencies in a package, so this will not be too bad. This only includes type definitions, which is scrubbed when transpiling anyways so no bundle penalty.
    • No support for AppSheet fetch API yet. I imagine this will be exactly the same but without Promises in the service clients.

    • chore: add syntaxv1 proto pkg
    • feat: generate message type stubs
    • feat: generate scalar fields
    • feat: generate comments
    • feat: support nested messages
    • feat: generate comment for nested messages
    • feat: generate top level enums
    • fix: trim leading whitespace in comments
    • feat: generate nested enums
    • feat: support map fields
    • refactor: generic descriptor type name
    • chore: add all well known types to syntax message
    • feat: support JSON-special well known types
    • fix: map sint32 and sint64 scalars
    • feat: support message and enum fields
    • chore: add forwarded message in syntax
    • feat: inline imported types
    • refactor: clean up helpers
    • chore: add syntax service
    • feat: generate service interface
    • feat: add httprule pkg
    • feat: add service client stub
    • feat: map path fields to request
    • feat: map body to request
    • feat: map query parameters to request
    • feat: set method
    opened by ericwenn 1
  • chore(deps): bump actions/checkout from 2 to 2.3.4

    chore(deps): bump actions/checkout from 2 to 2.3.4

    Bumps actions/checkout from 2 to 2.3.4.

    Release notes

    Sourced from actions/checkout's releases.

    v2.3.4

    v2.3.3

    v2.3.2

    Add Third Party License Information to Dist Files

    v2.3.1

    Fix default branch resolution for .wiki and when using SSH

    v2.3.0

    Fallback to the default branch

    v2.2.0

    Fetch all history for all tags and branches when fetch-depth=0

    v2.1.1

    Changes to support GHES (here and here)

    v2.1.0

    Changelog

    Sourced from actions/checkout's changelog.

    Changelog

    v2.3.1

    v2.3.0

    v2.2.0

    v2.1.1

    • Changes to support GHES (here and here)

    v2.1.0

    v2.0.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.

    Dependabot will merge this PR once CI passes on it, as requested by @ericwenn.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 0
  • chore(deps): bump actions/setup-node from 2.2.0 to 2.4.0

    chore(deps): bump actions/setup-node from 2.2.0 to 2.4.0

    Bumps actions/setup-node from 2.2.0 to 2.4.0.

    Release notes

    Sourced from actions/setup-node's releases.

    Support caching for mono repos and repositories with complex structure

    This release introduces dependency caching support for mono repos and repositories with complex structure (#305).

    By default, the action searches for the dependency file (package-lock.json or yarn.lock) in the repository root. Use the cache-dependency-path input for cases when multiple dependency files are used, or they are located in different subdirectories. This input supports wildcards or a list of file names for caching multiple dependencies.

    Yaml example:

    steps:
    - uses: actions/[email protected]
    - uses: actions/[email protected]
      with:
        node-version: 14
        cache: npm
        cache-dependency-path: 'sub-project/package-lock.json'
    

    For more examples of using cache-dependency-path input, see the Advanced usage guide.

    Revert temporary fix

    We had to disable pre-cached Node.js usage in the previous version due to the broken image cache. Now cache is fixed, so we can safely enable its usage again. Thank you for understanding.

    Temporary maintenance fix.

    Temporarily disabled usage of pre-cached Node.js.

    Support caching pnpm dependencies

    This release introduces dependency caching support for the pnpm package manager (#278).

    Caching pnpm dependencies:

    # This workflow uses actions that are not certified by GitHub.
    # They are provided by a third-party and are governed by
    # separate terms of service, privacy policy, and support
    # documentation.
    

    steps:

  • NOTE: pnpm caching support requires pnpm version >= 6.10.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    dependencies github_actions  opened by dependabot[bot] 0
  • fix: dont panic on methods without http rules

    fix: dont panic on methods without http rules

    • httprule.Get returns !ok when there is no http rule annotation
    • use nil safe field accessors for http rules
    opened by ericwenn 0
  • Releases(v0.6.1)
    Owner
    Einride
    Intelligent movement
    Einride
    Easily generate gRPC services in Go ⚡️

    Lile is a application generator (think create-react-app, rails new or django startproject) for gRPC services in Go and a set of tools/libraries. The p

    Lile 1.4k Sep 12, 2021
    A pluggable backend API that enforces the Event Sourcing Pattern for persisting & broadcasting application state changes

    A pluggable "Application State Gateway" that enforces the Event Sourcing Pattern for securely persisting & broadcasting application state changes

    null 25 Aug 26, 2021
    🎉 An awesome version control tool for protoc and its related plugins.

    ❤️ PowerProto is actively maintained! Any questions in use can be directly raised issue, I will respond to you as fast as possible. If you think the p

    storyicon 103 Sep 12, 2021
    Generate types and service clients from protobuf definitions annotated with http rules.

    protoc-gen-typescript-http Generates Typescript types and service clients from protobuf definitions annotated with http rules. The generated types fol

    Einride 14 Aug 6, 2021
    Fast time-series data storage server accessible over gRPC

    tstorage-server Persistent fast time-series data storage server accessible over gRPC. tstorage-server is lightweight local on-disk storage engine serv

    Bartlomiej Mika 4 Aug 3, 2021
    📦 Command line peer-to-peer data transfer tool based on libp2p.

    pcp - Peer Copy Command line peer-to-peer data transfer tool based on libp2p. Table of Contents Motivation Project Status How does it work? Usage Inst

    Dennis Trautwein 783 Sep 10, 2021
    Protobuf files manager

    Prot - protobuf files manager. It application can help your manage protobuf files and generate code based on him. !!! Before use Prot you must install

    Maksim Pavlov 5 Dec 21, 2020
    A simple RPC framework with protobuf service definitions

    Twirp is a framework for service-to-service communication emphasizing simplicity and minimalism. It generates routing and serialization from API defin

    Twitch 5.1k Sep 10, 2021
    A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.

    frp README | 中文文档 What is frp? frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the Internet. As of now, it s

    null 48.2k Sep 12, 2021
    🚀Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.

    gev 中文 | English gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily bui

    徐旭 1.2k Sep 7, 2021
    A Protocol Buffers compiler that generates optimized marshaling & unmarshaling Go code for ProtoBuf APIv2

    vtprotobuf, the Vitess Protocol Buffers compiler This repository provides the protoc-gen-go-vtproto plug-in for protoc, which is used by Vitess to gen

    PlanetScale 314 Sep 10, 2021
    A Realtime API Gateway used with NATS to build REST, real time, and RPC APIs, where all your clients are synchronized seamlessly.

    Realtime API Gateway Synchronize Your Clients Visit Resgate.io for guides, live demos, and resources. Resgate is a Go project implementing a realtime

    Resgate.io - Synchronize Your Clients 510 Sep 10, 2021
    HTTP(S)/WS(S)/TCP Tunnels to localhost using only SSH.

    An open source serveo/ngrok alternative.

    Antonio Mika 2k Sep 15, 2021
    TGameServer

    TGameServer TGame服务端 使用Go + TCP + UDP +My doc: https://github.com/ALEXTANGXIAO/TGameServer 客户端地址: https://github.com/ALEXTANGXIAO/TGameUnity Tested on

    ALEXTANG 19 Aug 26, 2021
    Hprose 1.0 for Golang (Deprecated). Hprose 2.0 for Golang is here:

    Hprose for Golang Introduction Installation Usage Http Server Http Client Synchronous Invoking Synchronous Exception Handling Asynchronous Invoking As

    Hprose 138 Jun 28, 2021
    Seesaw v2 is a Linux Virtual Server (LVS) based load balancing platform.

    Seesaw v2 Note: This is not an official Google product. About Seesaw v2 is a Linux Virtual Server (LVS) based load balancing platform. It is capable o

    Google 5.3k Sep 9, 2021
    webrpc is a schema-driven approach to writing backend services for modern Web apps and networks

    webrpc is a schema-driven approach to writing backend servers for the Web. Write your server's api interface in a schema format of RIDL or JSON, and t

    null 386 Aug 23, 2021
    A Filecoin Network sidecar for miners to bid in storage deal auctions.

    bidbot Bidbot is a Filecoin Network sidecar for miners to bid in storage deal auctions. Join us on our public Slack channel for news, discussions, and

    textile.io 13 Sep 14, 2021
    COGS: COnfiguration manaGement S.

    COGS: COnfiguration manaGement S cogs is a cli tool that allows generation of configuration files through different references sources. Sources of ref

    Bestow 4 Apr 30, 2021