protoc-gen-typescript-aip

command module
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2025 License: MIT Imports: 7 Imported by: 0

README

protoc-gen-typescript-aip

Generates Typescript helpers for Protobuf APIs conforming to AIP.

Install the plugin
go get go.einride.tech/protoc-gen-typescript-aip

Or download a prebuilt binary from releases.

Invocation
protoc
protoc 
  --typescript-aip_out [OUTPUT DIR] \
  [.proto files ...]
buf
plugins:
  - name: typescript-aip
    out: [OUTPUT DIR]
    strategy: all
Configuration
filename                Name of the file to generate the code to.
                        Default: `index.ts`.

insertion_point         If non-empty, indicates that the named file should already exist,
                        and the content here is to be inserted into that file at a defined 
                        insertion point. 

exclude_resource_definitions
                        If set to true, resource names will not be generated for resource definitions
                        in the file scope, only on messages. Default: false.

Features

Resource names

Generates helpers for working with resource names, based on ResourceDescriptor annotations.

Example

A resource annotated with

option (google.api.resource) = {
  type: "account-example.einride.tech/User"
  pattern: "tenants/{tenant}/users/{user}"
  singular: "user"
  plural: "users"
};

generates the following API

// Parsing a string:
const name = UserResourceName.parse("tenants/1/users/2")

// Getting variable segments:
console.log(name.tenant);     // "1"
console.log(name.user);       // "2"

// Getting the string back:
console.log(name.toString())  // "tenants/1/users/2"

// Traversing the resource hierarchy:
const tenant = name.tenantResourceName();
console.log(tenant.toString())  // "tenants/1"

// Constructing the resource name from segments:
const name = UserResourceName.from("tenant", "user")
console.log(name.tenant)        // "tenant"
console.log(name.user)          // "user"
console.log(name.toString())    // "tenants/tenant/users/user"

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL