This commit is contained in:
2025-04-12 12:38:00 +08:00
parent 5341dfcd1a
commit 52bfd05b80
47 changed files with 4730 additions and 2 deletions

2
examples/proto/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.build/
.tools/*/*/

64
examples/proto/Makefile Normal file
View File

@@ -0,0 +1,64 @@
# Code generated by go.einride.tech/sage. DO NOT EDIT.
# To learn more, see ../../.sage/main.go and https://github.com/einride/sage.
.DEFAULT_GOAL := all
cwd := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
sagefile := $(abspath $(cwd)/../../.sage/bin/sagefile)
# Setup Go.
go := $(shell command -v go 2>/dev/null)
export GOWORK ?= off
ifndef go
SAGE_GO_VERSION ?= 1.20.2
export GOROOT := $(abspath $(cwd)/../../.sage/tools/go/$(SAGE_GO_VERSION)/go)
export PATH := $(PATH):$(GOROOT)/bin
go := $(GOROOT)/bin/go
os := $(shell uname | tr '[:upper:]' '[:lower:]')
arch := $(shell uname -m)
ifeq ($(arch),x86_64)
arch := amd64
endif
$(go):
$(info installing Go $(SAGE_GO_VERSION)...)
@mkdir -p $(dir $(GOROOT))
@curl -sSL https://go.dev/dl/go$(SAGE_GO_VERSION).$(os)-$(arch).tar.gz | tar xz -C $(dir $(GOROOT))
@touch $(GOROOT)/go.mod
@chmod +x $(go)
endif
.PHONY: $(sagefile)
$(sagefile): $(go)
@cd ../../.sage && $(go) mod tidy && $(go) run .
.PHONY: sage
sage:
@$(MAKE) $(sagefile)
.PHONY: update-sage
update-sage: $(go)
@cd ../../.sage && $(go) get -d go.einride.tech/sage@latest && $(go) mod tidy && $(go) run .
.PHONY: clean-sage
clean-sage:
@git clean -fdx ../../.sage/tools ../../.sage/bin ../../.sage/build
.PHONY: all
all: $(sagefile)
@$(sagefile) Proto:All
.PHONY: buf-format
buf-format: $(sagefile)
@$(sagefile) Proto:BufFormat
.PHONY: buf-generate
buf-generate: $(sagefile)
@$(sagefile) Proto:BufGenerate
.PHONY: buf-lint
buf-lint: $(sagefile)
@$(sagefile) Proto:BufLint
.PHONY: build
build: $(sagefile)
@$(sagefile) Proto:Build

View File

@@ -0,0 +1,5 @@
version: v1
plugins:
- name: typescript-http
out: gen/typescript

7
examples/proto/buf.lock Normal file
View File

@@ -0,0 +1,7 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: d1263fe26f8e430a967dc22a4d0cad18

15
examples/proto/buf.yaml Normal file
View File

@@ -0,0 +1,15 @@
version: v1
name: buf.build/einride/protoc-gen-typescript-http
deps:
- buf.build/googleapis/googleapis
lint:
use:
- DEFAULT
except:
- RPC_REQUEST_STANDARD_NAME
- RPC_RESPONSE_STANDARD_NAME
- RPC_REQUEST_RESPONSE_UNIQUE
- ENUM_VALUE_PREFIX

View File

@@ -0,0 +1,371 @@
syntax = "proto3";
package einride.example.freight.v1;
import "einride/example/freight/v1/shipment.proto";
import "einride/example/freight/v1/shipper.proto";
import "einride/example/freight/v1/site.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/field_mask.proto";
// This API represents a simple freight service.
//
// It defines the following resource model:
//
// - The API has a collection of [Shipper][einride.example.freight.v1.Shipper]
// resources, named `shippers/*`
//
// - Each Shipper has a collection of [Site][einride.example.freight.v1.Site]
// resources, named `shippers/*/sites/*`
//
// - Each Shipper has a collection of [Shipment][einride.example.freight.v1.Shipment]
// resources, named `shippers/*/shipments/*`
service FreightService {
option (google.api.default_host) = "freight-example.einride.tech";
// Get a shipper.
// See: https://google.aip.dev/131 (Standard methods: Get).
rpc GetShipper(GetShipperRequest) returns (Shipper) {
option (google.api.http) = {get: "/v1/{name=shippers/*}"};
option (google.api.method_signature) = "name";
}
// List shippers.
// See: https://google.aip.dev/132 (Standard methods: List).
rpc ListShippers(ListShippersRequest) returns (ListShippersResponse) {
option (google.api.http) = {get: "/v1/shippers"};
}
// Create a shipper.
// See: https://google.aip.dev/133 (Standard methods: Create).
rpc CreateShipper(CreateShipperRequest) returns (Shipper) {
option (google.api.http) = {
post: "/v1/shippers"
body: "shipper"
};
option (google.api.method_signature) = "shipper";
}
// Update a shipper.
// See: https://google.aip.dev/134 (Standard methods: Update).
rpc UpdateShipper(UpdateShipperRequest) returns (Shipper) {
option (google.api.http) = {
patch: "/v1/{shipper.name=shippers/*}"
body: "shipper"
};
option (google.api.method_signature) = "shipper,update_mask";
}
// Delete a shipper.
// See: https://google.aip.dev/135 (Standard methods: Delete).
// See: https://google.aip.dev/164 (Soft delete).
rpc DeleteShipper(DeleteShipperRequest) returns (Shipper) {
option (google.api.http) = {delete: "/v1/{name=shippers/*}"};
option (google.api.method_signature) = "name";
}
// Get a site.
// See: https://google.aip.dev/131 (Standard methods: Get).
rpc GetSite(GetSiteRequest) returns (Site) {
option (google.api.http) = {get: "/v1/{name=shippers/*/sites/*}"};
option (google.api.method_signature) = "name";
}
// List sites for a shipper.
// See: https://google.aip.dev/132 (Standard methods: List).
rpc ListSites(ListSitesRequest) returns (ListSitesResponse) {
option (google.api.http) = {get: "/v1/{parent=shippers/*}/sites"};
option (google.api.method_signature) = "parent";
}
// Create a site.
// See: https://google.aip.dev/133 (Standard methods: Create).
rpc CreateSite(CreateSiteRequest) returns (Site) {
option (google.api.http) = {
post: "/v1/{parent=shippers/*}/sites"
body: "site"
};
option (google.api.method_signature) = "parent,site";
}
// Update a site.
// See: https://google.aip.dev/134 (Standard methods: Update).
rpc UpdateSite(UpdateSiteRequest) returns (Site) {
option (google.api.http) = {
patch: "/v1/{site.name=shippers/*/sites/*}"
body: "site"
};
option (google.api.method_signature) = "site,update_mask";
}
// Delete a site.
// See: https://google.aip.dev/135 (Standard methods: Delete).
// See: https://google.aip.dev/164 (Soft delete).
rpc DeleteSite(DeleteSiteRequest) returns (Site) {
option (google.api.http) = {delete: "/v1/{name=shippers/*/sites/*}"};
option (google.api.method_signature) = "name";
}
// Get a shipment.
// See: https://google.aip.dev/131 (Standard methods: Get).
rpc GetShipment(GetShipmentRequest) returns (Shipment) {
option (google.api.http) = {get: "/v1/{name=shippers/*/shipments/*}"};
option (google.api.method_signature) = "name";
}
// List shipments for a shipper.
// See: https://google.aip.dev/132 (Standard methods: List).
rpc ListShipments(ListShipmentsRequest) returns (ListShipmentsResponse) {
option (google.api.http) = {get: "/v1/{parent=shippers/*}/shipments"};
option (google.api.method_signature) = "parent";
}
// Create a shipment.
// See: https://google.aip.dev/133 (Standard methods: Create).
rpc CreateShipment(CreateShipmentRequest) returns (Shipment) {
option (google.api.http) = {
post: "/v1/{parent=shippers/*}/shipments"
body: "shipment"
};
option (google.api.method_signature) = "parent,shipment";
}
// Update a shipment.
// See: https://google.aip.dev/134 (Standard methods: Update).
rpc UpdateShipment(UpdateShipmentRequest) returns (Shipment) {
option (google.api.http) = {
patch: "/v1/{shipment.name=shippers/*/shipments/*}"
body: "shipment"
};
option (google.api.method_signature) = "shipment,update_mask";
}
// Delete a shipment.
// See: https://google.aip.dev/135 (Standard methods: Delete).
// See: https://google.aip.dev/164 (Soft delete).
rpc DeleteShipment(DeleteShipmentRequest) returns (Shipment) {
option (google.api.http) = {delete: "/v1/{name=shippers/*/shipments/*}"};
option (google.api.method_signature) = "name";
}
}
// Request message for FreightService.GetShipper.
message GetShipperRequest {
// The resource name of the shipper to retrieve.
// Format: shippers/{shipper}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference).type = "freight-example.einride.tech/Shipper"
];
}
// Request message for FreightService.ListShippers.
message ListShippersRequest {
// Requested page size. Server may return fewer shippers than requested.
// If unspecified, server will pick an appropriate default.
int32 page_size = 1;
// A token identifying a page of results the server should return.
// Typically, this is the value of
// [ListShippersResponse.next_page_token][einride.example.freight.v1.ListShippersResponse.next_page_token]
// returned from the previous call to `ListShippers` method.
string page_token = 2;
}
// Response message for FreightService.ListShippers.
message ListShippersResponse {
// The list of shippers.
repeated Shipper shippers = 1;
// A token to retrieve next page of results. Pass this value in the
// [ListShippersRequest.page_token][einride.example.freight.v1.ListShippersRequest.page_token]
// field in the subsequent call to `ListShippers` method to retrieve the next
// page of results.
string next_page_token = 2;
}
// Request message for FreightService.CreateShipper.
message CreateShipperRequest {
// The shipper to create.
Shipper shipper = 1 [(google.api.field_behavior) = REQUIRED];
}
// Request message for FreightService.UpdateShipper.
message UpdateShipperRequest {
// The shipper to update with. The name must match or be empty.
// The shipper's `name` field is used to identify the shipper to be updated.
// Format: shippers/{shipper}
Shipper shipper = 1 [(google.api.field_behavior) = REQUIRED];
// The list of fields to be updated.
google.protobuf.FieldMask update_mask = 2;
}
// Request message for FreightService.DeleteShipper.
message DeleteShipperRequest {
// The resource name of the shipper to delete.
// Format: shippers/{shipper}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference).type = "freight-example.einride.tech/Shipper"
];
}
// Request message for FreightService.GetSite.
message GetSiteRequest {
// The resource name of the site to retrieve.
// Format: shippers/{shipper}/sites/{site}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference).type = "freight-example.einride.tech/Site"
];
}
// Request message for FreightService.ListSites.
message ListSitesRequest {
// The resource name of the parent, which owns this collection of sites.
// Format: shippers/{shipper}
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "freight-example.einride.tech/Shipper"
child_type: "freight-example.einride.tech/Site"
}
];
// Requested page size. Server may return fewer sites than requested.
// If unspecified, server will pick an appropriate default.
int32 page_size = 2;
// A token identifying a page of results the server should return.
// Typically, this is the value of
// [ListSitesResponse.next_page_token][einride.example.freight.v1.ListSitesResponse.next_page_token]
// returned from the previous call to `ListSites` method.
string page_token = 3;
}
// Response message for FreightService.ListSites.
message ListSitesResponse {
// The list of sites.
repeated Site sites = 1;
// A token to retrieve next page of results. Pass this value in the
// [ListSitesRequest.page_token][einride.example.freight.v1.ListSitesRequest.page_token]
// field in the subsequent call to `ListSites` method to retrieve the next
// page of results.
string next_page_token = 2;
}
// Request message for FreightService.CreateSite.
message CreateSiteRequest {
// The resource name of the parent shipper for which this site will be created.
// Format: shippers/{shipper}
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {child_type: "freight-example.einride.tech/Shipper"}
];
// The site to create.
Site site = 2 [(google.api.field_behavior) = REQUIRED];
}
// Request message for FreightService.UpdateSite.
message UpdateSiteRequest {
// The site to update with. The name must match or be empty.
// The site's `name` field is used to identify the site to be updated.
// Format: shippers/{shipper}/sites/{site}
Site site = 1 [(google.api.field_behavior) = REQUIRED];
// The list of fields to be updated.
google.protobuf.FieldMask update_mask = 2;
}
// Request message for FreightService.DeleteSite.
message DeleteSiteRequest {
// The resource name of the site to delete.
// Format: shippers/{shipper}/sites/{site}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference).type = "freight-example.einride.tech/Site"
];
}
// Request message for FreightService.GetShipment.
message GetShipmentRequest {
// The resource name of the shipment to retrieve.
// Format: shippers/{shipper}/shipments/{shipment}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference).type = "freight-example.einride.tech/Shipment"
];
}
// Request message for FreightService.ListShipments.
message ListShipmentsRequest {
// The resource name of the parent, which owns this collection of shipments.
// Format: shippers/{shipper}
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "freight-example.einride.tech/Shipper"
child_type: "freight-example.einride.tech/Shipment"
}
];
// Requested page size. Server may return fewer shipments than requested.
// If unspecified, server will pick an appropriate default.
int32 page_size = 2;
// A token identifying a page of results the server should return.
// Typically, this is the value of
// [ListShipmentsResponse.next_page_token][einride.example.freight.v1.ListShipmentsResponse.next_page_token]
// returned from the previous call to `ListShipments` method.
string page_token = 3;
}
// Response message for FreightService.ListShipments.
message ListShipmentsResponse {
// The list of shipments.
repeated Shipment shipments = 1;
// A token to retrieve next page of results. Pass this value in the
// [ListShipmentsRequest.page_token][einride.example.freight.v1.ListShipmentsRequest.page_token]
// field in the subsequent call to `ListShipments` method to retrieve the next
// page of results.
string next_page_token = 2;
}
// Request message for FreightService.CreateShipment.
message CreateShipmentRequest {
// The resource name of the parent shipper for which this shipment will be created.
// Format: shippers/{shipper}
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {child_type: "freight-example.einride.tech/Shipper"}
];
// The shipment to create.
Shipment shipment = 2 [(google.api.field_behavior) = REQUIRED];
}
// Request message for FreightService.UpdateShipment.
message UpdateShipmentRequest {
// The shipment to update with. The name must match or be empty.
// The shipment's `name` field is used to identify the shipment to be updated.
// Format: shippers/{shipper}/shipments/{shipment}
Shipment shipment = 1 [(google.api.field_behavior) = REQUIRED];
// The list of fields to be updated.
google.protobuf.FieldMask update_mask = 2;
}
// Request message for FreightService.DeleteShipment.
message DeleteShipmentRequest {
// The resource name of the shipment to delete.
// Format: shippers/{shipper}/shipments/{shipment}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference).type = "freight-example.einride.tech/Shipment"
];
}

View File

@@ -0,0 +1,77 @@
syntax = "proto3";
package einride.example.freight.v1;
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";
// A shipment represents transportation of goods between an origin
// [site][einride.example.freight.v1.Site] and a destination
// [site][einride.example.freight.v1.Site].
message Shipment {
option (google.api.resource) = {
type: "freight-example.einride.tech/Shipment"
pattern: "shippers/{shipper}/shipments/{shipment}"
singular: "shipment"
plural: "shipments"
};
// The resource name of the shipment.
string name = 1;
// The creation timestamp of the shipment.
google.protobuf.Timestamp create_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
// The last update timestamp of the shipment.
//
// Updated when create/update/delete operation is shipment.
google.protobuf.Timestamp update_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
// The deletion timestamp of the shipment.
google.protobuf.Timestamp delete_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
// The resource name of the origin site of the shipment.
// Format: shippers/{shipper}/sites/{site}
string origin_site = 5 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference).type = "freight-example.einride.tech/Site"
];
// The resource name of the destination site of the shipment.
// Format: shippers/{shipper}/sites/{site}
string destination_site = 6 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference).type = "freight-example.einride.tech/Site"
];
// The earliest pickup time of the shipment at the origin site.
google.protobuf.Timestamp pickup_earliest_time = 7 [(google.api.field_behavior) = REQUIRED];
// The latest pickup time of the shipment at the origin site.
google.protobuf.Timestamp pickup_latest_time = 8 [(google.api.field_behavior) = REQUIRED];
// The earliest delivery time of the shipment at the destination site.
google.protobuf.Timestamp delivery_earliest_time = 9 [(google.api.field_behavior) = REQUIRED];
// The latest delivery time of the shipment at the destination site.
google.protobuf.Timestamp delivery_latest_time = 10 [(google.api.field_behavior) = REQUIRED];
// The line items of the shipment.
repeated LineItem line_items = 11;
// Annotations of the shipment.
map<string, string> annotations = 12;
}
// A shipment line item.
message LineItem {
// The title of the line item.
string title = 1;
// The quantity of the line item.
float quantity = 2;
// The weight of the line item in kilograms.
float weight_kg = 3;
// The volume of the line item in cubic meters.
float volume_m3 = 4;
}

View File

@@ -0,0 +1,29 @@
syntax = "proto3";
package einride.example.freight.v1;
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";
// A shipper is a supplier or owner of goods to be transported.
message Shipper {
option (google.api.resource) = {
type: "freight-example.einride.tech/Shipper"
pattern: "shippers/{shipper}"
singular: "shipper"
plural: "shippers"
};
// The resource name of the shipper.
string name = 1;
// The creation timestamp of the shipper.
google.protobuf.Timestamp create_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
// The last update timestamp of the shipper.
//
// Updated when create/update/delete operation is performed.
google.protobuf.Timestamp update_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
// The deletion timestamp of the shipper.
google.protobuf.Timestamp delete_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
// The display name of the shipper.
string display_name = 5 [(google.api.field_behavior) = REQUIRED];
}

View File

@@ -0,0 +1,33 @@
syntax = "proto3";
package einride.example.freight.v1;
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";
import "google/type/latlng.proto";
// A site is a node in a [shipper][einride.example.freight.v1.Shipper]'s
// transport network.
message Site {
option (google.api.resource) = {
type: "freight-example.einride.tech/Site"
pattern: "shippers/{shipper}/sites/{site}"
singular: "site"
plural: "sites"
};
// The resource name of the site.
string name = 1;
// The creation timestamp of the site.
google.protobuf.Timestamp create_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
// The last update timestamp of the site.
//
// Updated when create/update/delete operation is performed.
google.protobuf.Timestamp update_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
// The deletion timestamp of the site.
google.protobuf.Timestamp delete_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
// The display name of the site.
string display_name = 5 [(google.api.field_behavior) = REQUIRED];
// The geographic location of the site.
google.type.LatLng lat_lng = 6;
}

View File

@@ -0,0 +1,240 @@
syntax = "proto3";
package einride.example.syntax.v1;
import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/wrappers.proto";
// Message
message Message {
// NestedMessage
message NestedMessage {
// nested_message.string
string string = 1;
}
// NestedEnum
enum NestedEnum {
// NESTEDENUM_UNSPECIFIED
NESTEDENUM_UNSPECIFIED = 0;
}
// double
double double = 1;
// float
float float = 2;
// int32
int32 int32 = 3;
// int64
int64 int64 = 4;
// uint32
uint32 uint32 = 5;
// uint64
uint64 uint64 = 6;
// sint32
sint32 sint32 = 7;
// sint64
sint64 sint64 = 8;
// fixed32
fixed32 fixed32 = 9;
// fixed64
fixed64 fixed64 = 10;
// sfixed32
sfixed32 sfixed32 = 11;
// sfixed64
sfixed64 sfixed64 = 12;
// bool
bool bool = 13;
// string
string string = 14;
// bytes
bytes bytes = 15;
// enum
Enum enum = 16;
// message
Message message = 17;
// optional double
optional double optional_double = 81;
// optional float
optional float optional_float = 82;
// optional int32
optional int32 optional_int32 = 83;
// optional int64
optional int64 optional_int64 = 84;
// optional uint32
optional uint32 optional_uint32 = 85;
// optional uint64
optional uint64 optional_uint64 = 86;
// optional sint32
optional sint32 optional_sint32 = 87;
// optional sint64
optional sint64 optional_sint64 = 88;
// optional fixed32
optional fixed32 optional_fixed32 = 89;
// optional fixed64
optional fixed64 optional_fixed64 = 90;
// optional sfixed32
optional sfixed32 optional_sfixed32 = 91;
// optional sfixed64
optional sfixed64 optional_sfixed64 = 92;
// optional bool
optional bool optional_bool = 93;
// optional string
optional string optional_string = 94;
// optional bytes
optional bytes optional_bytes = 95;
// optional enum
optional Enum optional_enum = 96;
// optional message
optional Message optional_message = 97;
// repeated_double
repeated double repeated_double = 18;
// repeated_float
repeated float repeated_float = 19;
// repeated_int32
repeated int32 repeated_int32 = 20;
// repeated_int64
repeated int64 repeated_int64 = 21;
// repeated_uint32
repeated uint32 repeated_uint32 = 22;
// repeated_uint64
repeated uint64 repeated_uint64 = 23;
// repeated_sint32
repeated sint32 repeated_sint32 = 24;
// repeated_sint64
repeated sint64 repeated_sint64 = 25;
// repeated_fixed32
repeated fixed32 repeated_fixed32 = 26;
// repeated_fixed64
repeated fixed64 repeated_fixed64 = 27;
// repeated_sfixed32
repeated sfixed32 repeated_sfixed32 = 28;
// repeated_sfixed64
repeated sfixed64 repeated_sfixed64 = 29;
// repeated_bool
repeated bool repeated_bool = 30;
// repeated_string
repeated string repeated_string = 31;
// repeated_bytes
repeated bytes repeated_bytes = 32;
// repeated_enum
repeated Enum repeated_enum = 33;
// repeated_message
repeated Message repeated_message = 34;
// map_string_string
map<string, string> map_string_string = 35;
// map_string_message
map<string, Message> map_string_message = 36;
// oneof
oneof oneof {
// oneof_string
string oneof_string = 37;
// oneof_enum
Enum oneof_enum = 38;
// oneof_message1
Message oneof_message1 = 39;
// oneof_message2
Message oneof_message2 = 40;
}
// any
google.protobuf.Any any = 41;
// repeated_any
repeated google.protobuf.Any repeated_any = 42;
// duration
google.protobuf.Duration duration = 43;
// repeated_duration
repeated google.protobuf.Duration repeated_duration = 44;
// empty
google.protobuf.Empty empty = 45;
// repeated_empty
repeated google.protobuf.Empty repeated_empty = 46;
// field_mask
google.protobuf.FieldMask field_mask = 47;
// repeated_field_mask
repeated google.protobuf.FieldMask repeated_field_mask = 48;
// struct
google.protobuf.Struct struct = 49;
// repeated_struct
repeated google.protobuf.Struct repeated_struct = 50;
// value
google.protobuf.Value value = 51;
// repeated_value
repeated google.protobuf.Value repeated_value = 52;
// null_value
google.protobuf.NullValue null_value = 53;
// repeated_null_value
repeated google.protobuf.NullValue repeated_null_value = 54;
// list_value
google.protobuf.ListValue list_value = 55;
// repeated_list_value
repeated google.protobuf.ListValue repeated_list_value = 56;
// bool_value
google.protobuf.BoolValue bool_value = 57;
// repeated_bool_value
repeated google.protobuf.BoolValue repeated_bool_value = 58;
// bytes_value
google.protobuf.BytesValue bytes_value = 59;
// repeated_bytes_value
repeated google.protobuf.BytesValue repeated_bytes_value = 60;
// double_value
google.protobuf.DoubleValue double_value = 61;
// repeated_double_value
repeated google.protobuf.DoubleValue repeated_double_value = 62;
// float_value
google.protobuf.FloatValue float_value = 63;
// repeated_float_value
repeated google.protobuf.FloatValue repeated_float_value = 64;
// int32_value
google.protobuf.Int32Value int32_value = 65;
// repeated_int32_value
repeated google.protobuf.Int32Value repeated_int32_value = 66;
// int64_value
google.protobuf.Int64Value int64_value = 67;
// repeated_int64_value
repeated google.protobuf.Int64Value repeated_int64_value = 68;
// uint32_value
google.protobuf.UInt32Value uint32_value = 69;
// repeated_uint32_value
repeated google.protobuf.UInt32Value repeated_uint32_value = 70;
// uint64_value
google.protobuf.UInt64Value uint64_value = 71;
// repeated_uint64_value
repeated google.protobuf.UInt64Value repeated_uint64_value = 72;
// string_value
google.protobuf.UInt64Value string_value = 73;
// repeated_string_value
repeated google.protobuf.StringValue repeated_string_value = 74;
}
// Enum
enum Enum {
// ENUM_UNSPECIFIED
ENUM_UNSPECIFIED = 0;
// ENUM_ONE
ENUM_ONE = 1;
// ENUM_TWO
ENUM_TWO = 2;
}

View File

@@ -0,0 +1,51 @@
syntax = "proto3";
package einride.example.syntax.v1;
import "einride/example/syntax/v1/syntax.proto";
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
service SyntaxService {
rpc QueryOnly(Request) returns (Message) {
option (google.api.http) = {get: "/v1"};
}
rpc EmptyVerb(google.protobuf.Empty) returns (google.protobuf.Empty) {
option (google.api.http) = {get: "/v1:emptyVerb"};
}
rpc StarBody(Request) returns (Message) {
option (google.api.http) = {
post: "/v1:starBody"
body: "*"
};
}
rpc Body(Request) returns (Message) {
option (google.api.http) = {
post: "/v1:body"
body: "nested"
};
}
rpc Path(Request) returns (Message) {
option (google.api.http) = {post: "/v1/{string}:path"};
}
rpc PathBody(Request) returns (Message) {
option (google.api.http) = {
post: "/v1/{string}:pathBody"
body: "nested"
};
}
}
message Request {
string string = 1;
repeated string repeated_string = 2;
message Nested {
string string = 1;
}
Nested nested = 3;
}

View File

@@ -0,0 +1,11 @@
syntax = "proto3";
package einride.example.syntax.v2;
import "einride/example/syntax/v1/syntax.proto";
// Message
message Message {
einride.example.syntax.v1.Message forwarded_message = 1;
einride.example.syntax.v1.Enum forwarded_enum = 2;
}

View File

@@ -0,0 +1,760 @@
// Code generated by protoc-gen-typescript-http. DO NOT EDIT.
/* eslint-disable camelcase */
// @ts-nocheck
// A shipment represents transportation of goods between an origin
// [site][einride.example.freight.v1.Site] and a destination
// [site][einride.example.freight.v1.Site].
export type Shipment = {
// The resource name of the shipment.
name: string | undefined;
// The creation timestamp of the shipment.
//
// Behaviors: OUTPUT_ONLY
createTime: wellKnownTimestamp | undefined;
// The last update timestamp of the shipment.
// Updated when create/update/delete operation is shipment.
//
// Behaviors: OUTPUT_ONLY
updateTime: wellKnownTimestamp | undefined;
// The deletion timestamp of the shipment.
//
// Behaviors: OUTPUT_ONLY
deleteTime: wellKnownTimestamp | undefined;
// The resource name of the origin site of the shipment.
// Format: shippers/{shipper}/sites/{site}
//
// Behaviors: REQUIRED
originSite: string | undefined;
// The resource name of the destination site of the shipment.
// Format: shippers/{shipper}/sites/{site}
//
// Behaviors: REQUIRED
destinationSite: string | undefined;
// The earliest pickup time of the shipment at the origin site.
//
// Behaviors: REQUIRED
pickupEarliestTime: wellKnownTimestamp | undefined;
// The latest pickup time of the shipment at the origin site.
//
// Behaviors: REQUIRED
pickupLatestTime: wellKnownTimestamp | undefined;
// The earliest delivery time of the shipment at the destination site.
//
// Behaviors: REQUIRED
deliveryEarliestTime: wellKnownTimestamp | undefined;
// The latest delivery time of the shipment at the destination site.
//
// Behaviors: REQUIRED
deliveryLatestTime: wellKnownTimestamp | undefined;
// The line items of the shipment.
lineItems: LineItem[] | undefined;
// Annotations of the shipment.
annotations: { [key: string]: string } | undefined;
};
// Encoded using RFC 3339, where generated output will always be Z-normalized
// and uses 0, 3, 6 or 9 fractional digits.
// Offsets other than "Z" are also accepted.
type wellKnownTimestamp = string;
// A shipment line item.
export type LineItem = {
// The title of the line item.
title: string | undefined;
// The quantity of the line item.
quantity: number | undefined;
// The weight of the line item in kilograms.
weightKg: number | undefined;
// The volume of the line item in cubic meters.
volumeM3: number | undefined;
};
// A shipper is a supplier or owner of goods to be transported.
export type Shipper = {
// The resource name of the shipper.
name: string | undefined;
// The creation timestamp of the shipper.
//
// Behaviors: OUTPUT_ONLY
createTime: wellKnownTimestamp | undefined;
// The last update timestamp of the shipper.
// Updated when create/update/delete operation is performed.
//
// Behaviors: OUTPUT_ONLY
updateTime: wellKnownTimestamp | undefined;
// The deletion timestamp of the shipper.
//
// Behaviors: OUTPUT_ONLY
deleteTime: wellKnownTimestamp | undefined;
// The display name of the shipper.
//
// Behaviors: REQUIRED
displayName: string | undefined;
};
// A site is a node in a [shipper][einride.example.freight.v1.Shipper]'s
// transport network.
export type Site = {
// The resource name of the site.
name: string | undefined;
// The creation timestamp of the site.
//
// Behaviors: OUTPUT_ONLY
createTime: wellKnownTimestamp | undefined;
// The last update timestamp of the site.
// Updated when create/update/delete operation is performed.
//
// Behaviors: OUTPUT_ONLY
updateTime: wellKnownTimestamp | undefined;
// The deletion timestamp of the site.
//
// Behaviors: OUTPUT_ONLY
deleteTime: wellKnownTimestamp | undefined;
// The display name of the site.
//
// Behaviors: REQUIRED
displayName: string | undefined;
// The geographic location of the site.
latLng: googletype_LatLng | undefined;
};
// An object that represents a latitude/longitude pair. This is expressed as a
// pair of doubles to represent degrees latitude and degrees longitude. Unless
// specified otherwise, this must conform to the
// <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84
// standard</a>. Values must be within normalized ranges.
export type googletype_LatLng = {
// The latitude in degrees. It must be in the range [-90.0, +90.0].
latitude: number | undefined;
// The longitude in degrees. It must be in the range [-180.0, +180.0].
longitude: number | undefined;
};
// Request message for FreightService.GetShipper.
export type GetShipperRequest = {
// The resource name of the shipper to retrieve.
// Format: shippers/{shipper}
//
// Behaviors: REQUIRED
name: string | undefined;
};
// Request message for FreightService.ListShippers.
export type ListShippersRequest = {
// Requested page size. Server may return fewer shippers than requested.
// If unspecified, server will pick an appropriate default.
pageSize: number | undefined;
// A token identifying a page of results the server should return.
// Typically, this is the value of
// [ListShippersResponse.next_page_token][einride.example.freight.v1.ListShippersResponse.next_page_token]
// returned from the previous call to `ListShippers` method.
pageToken: string | undefined;
};
// Response message for FreightService.ListShippers.
export type ListShippersResponse = {
// The list of shippers.
shippers: Shipper[] | undefined;
// A token to retrieve next page of results. Pass this value in the
// [ListShippersRequest.page_token][einride.example.freight.v1.ListShippersRequest.page_token]
// field in the subsequent call to `ListShippers` method to retrieve the next
// page of results.
nextPageToken: string | undefined;
};
// Request message for FreightService.CreateShipper.
export type CreateShipperRequest = {
// The shipper to create.
//
// Behaviors: REQUIRED
shipper: Shipper | undefined;
};
// Request message for FreightService.UpdateShipper.
export type UpdateShipperRequest = {
// The shipper to update with. The name must match or be empty.
// The shipper's `name` field is used to identify the shipper to be updated.
// Format: shippers/{shipper}
//
// Behaviors: REQUIRED
shipper: Shipper | undefined;
// The list of fields to be updated.
updateMask: wellKnownFieldMask | undefined;
};
// In JSON, a field mask is encoded as a single string where paths are
// separated by a comma. Fields name in each path are converted
// to/from lower-camel naming conventions.
// As an example, consider the following message declarations:
//
// message Profile {
// User user = 1;
// Photo photo = 2;
// }
// message User {
// string display_name = 1;
// string address = 2;
// }
//
// In proto a field mask for `Profile` may look as such:
//
// mask {
// paths: "user.display_name"
// paths: "photo"
// }
//
// In JSON, the same mask is represented as below:
//
// {
// mask: "user.displayName,photo"
// }
type wellKnownFieldMask = string;
// Request message for FreightService.DeleteShipper.
export type DeleteShipperRequest = {
// The resource name of the shipper to delete.
// Format: shippers/{shipper}
//
// Behaviors: REQUIRED
name: string | undefined;
};
// Request message for FreightService.GetSite.
export type GetSiteRequest = {
// The resource name of the site to retrieve.
// Format: shippers/{shipper}/sites/{site}
//
// Behaviors: REQUIRED
name: string | undefined;
};
// Request message for FreightService.ListSites.
export type ListSitesRequest = {
// The resource name of the parent, which owns this collection of sites.
// Format: shippers/{shipper}
//
// Behaviors: REQUIRED
parent: string | undefined;
// Requested page size. Server may return fewer sites than requested.
// If unspecified, server will pick an appropriate default.
pageSize: number | undefined;
// A token identifying a page of results the server should return.
// Typically, this is the value of
// [ListSitesResponse.next_page_token][einride.example.freight.v1.ListSitesResponse.next_page_token]
// returned from the previous call to `ListSites` method.
pageToken: string | undefined;
};
// Response message for FreightService.ListSites.
export type ListSitesResponse = {
// The list of sites.
sites: Site[] | undefined;
// A token to retrieve next page of results. Pass this value in the
// [ListSitesRequest.page_token][einride.example.freight.v1.ListSitesRequest.page_token]
// field in the subsequent call to `ListSites` method to retrieve the next
// page of results.
nextPageToken: string | undefined;
};
// Request message for FreightService.CreateSite.
export type CreateSiteRequest = {
// The resource name of the parent shipper for which this site will be created.
// Format: shippers/{shipper}
//
// Behaviors: REQUIRED
parent: string | undefined;
// The site to create.
//
// Behaviors: REQUIRED
site: Site | undefined;
};
// Request message for FreightService.UpdateSite.
export type UpdateSiteRequest = {
// The site to update with. The name must match or be empty.
// The site's `name` field is used to identify the site to be updated.
// Format: shippers/{shipper}/sites/{site}
//
// Behaviors: REQUIRED
site: Site | undefined;
// The list of fields to be updated.
updateMask: wellKnownFieldMask | undefined;
};
// Request message for FreightService.DeleteSite.
export type DeleteSiteRequest = {
// The resource name of the site to delete.
// Format: shippers/{shipper}/sites/{site}
//
// Behaviors: REQUIRED
name: string | undefined;
};
// Request message for FreightService.GetShipment.
export type GetShipmentRequest = {
// The resource name of the shipment to retrieve.
// Format: shippers/{shipper}/shipments/{shipment}
//
// Behaviors: REQUIRED
name: string | undefined;
};
// Request message for FreightService.ListShipments.
export type ListShipmentsRequest = {
// The resource name of the parent, which owns this collection of shipments.
// Format: shippers/{shipper}
//
// Behaviors: REQUIRED
parent: string | undefined;
// Requested page size. Server may return fewer shipments than requested.
// If unspecified, server will pick an appropriate default.
pageSize: number | undefined;
// A token identifying a page of results the server should return.
// Typically, this is the value of
// [ListShipmentsResponse.next_page_token][einride.example.freight.v1.ListShipmentsResponse.next_page_token]
// returned from the previous call to `ListShipments` method.
pageToken: string | undefined;
};
// Response message for FreightService.ListShipments.
export type ListShipmentsResponse = {
// The list of shipments.
shipments: Shipment[] | undefined;
// A token to retrieve next page of results. Pass this value in the
// [ListShipmentsRequest.page_token][einride.example.freight.v1.ListShipmentsRequest.page_token]
// field in the subsequent call to `ListShipments` method to retrieve the next
// page of results.
nextPageToken: string | undefined;
};
// Request message for FreightService.CreateShipment.
export type CreateShipmentRequest = {
// The resource name of the parent shipper for which this shipment will be created.
// Format: shippers/{shipper}
//
// Behaviors: REQUIRED
parent: string | undefined;
// The shipment to create.
//
// Behaviors: REQUIRED
shipment: Shipment | undefined;
};
// Request message for FreightService.UpdateShipment.
export type UpdateShipmentRequest = {
// The shipment to update with. The name must match or be empty.
// The shipment's `name` field is used to identify the shipment to be updated.
// Format: shippers/{shipper}/shipments/{shipment}
//
// Behaviors: REQUIRED
shipment: Shipment | undefined;
// The list of fields to be updated.
updateMask: wellKnownFieldMask | undefined;
};
// Request message for FreightService.DeleteShipment.
export type DeleteShipmentRequest = {
// The resource name of the shipment to delete.
// Format: shippers/{shipper}/shipments/{shipment}
//
// Behaviors: REQUIRED
name: string | undefined;
};
// This API represents a simple freight service.
// It defines the following resource model:
// - The API has a collection of [Shipper][einride.example.freight.v1.Shipper]
// resources, named `shippers/*`
// - Each Shipper has a collection of [Site][einride.example.freight.v1.Site]
// resources, named `shippers/*/sites/*`
// - Each Shipper has a collection of [Shipment][einride.example.freight.v1.Shipment]
// resources, named `shippers/*/shipments/*`
export interface FreightService {
// Get a shipper.
// See: https://google.aip.dev/131 (Standard methods: Get).
GetShipper(request: GetShipperRequest): Promise<Shipper>;
// List shippers.
// See: https://google.aip.dev/132 (Standard methods: List).
ListShippers(request: ListShippersRequest): Promise<ListShippersResponse>;
// Create a shipper.
// See: https://google.aip.dev/133 (Standard methods: Create).
CreateShipper(request: CreateShipperRequest): Promise<Shipper>;
// Update a shipper.
// See: https://google.aip.dev/134 (Standard methods: Update).
UpdateShipper(request: UpdateShipperRequest): Promise<Shipper>;
// Delete a shipper.
// See: https://google.aip.dev/135 (Standard methods: Delete).
// See: https://google.aip.dev/164 (Soft delete).
DeleteShipper(request: DeleteShipperRequest): Promise<Shipper>;
// Get a site.
// See: https://google.aip.dev/131 (Standard methods: Get).
GetSite(request: GetSiteRequest): Promise<Site>;
// List sites for a shipper.
// See: https://google.aip.dev/132 (Standard methods: List).
ListSites(request: ListSitesRequest): Promise<ListSitesResponse>;
// Create a site.
// See: https://google.aip.dev/133 (Standard methods: Create).
CreateSite(request: CreateSiteRequest): Promise<Site>;
// Update a site.
// See: https://google.aip.dev/134 (Standard methods: Update).
UpdateSite(request: UpdateSiteRequest): Promise<Site>;
// Delete a site.
// See: https://google.aip.dev/135 (Standard methods: Delete).
// See: https://google.aip.dev/164 (Soft delete).
DeleteSite(request: DeleteSiteRequest): Promise<Site>;
// Get a shipment.
// See: https://google.aip.dev/131 (Standard methods: Get).
GetShipment(request: GetShipmentRequest): Promise<Shipment>;
// List shipments for a shipper.
// See: https://google.aip.dev/132 (Standard methods: List).
ListShipments(request: ListShipmentsRequest): Promise<ListShipmentsResponse>;
// Create a shipment.
// See: https://google.aip.dev/133 (Standard methods: Create).
CreateShipment(request: CreateShipmentRequest): Promise<Shipment>;
// Update a shipment.
// See: https://google.aip.dev/134 (Standard methods: Update).
UpdateShipment(request: UpdateShipmentRequest): Promise<Shipment>;
// Delete a shipment.
// See: https://google.aip.dev/135 (Standard methods: Delete).
// See: https://google.aip.dev/164 (Soft delete).
DeleteShipment(request: DeleteShipmentRequest): Promise<Shipment>;
}
type RequestType = {
path: string;
method: string;
body: string | null;
};
type RequestHandler = (request: RequestType, meta: { service: string, method: string }) => Promise<unknown>;
export function createFreightServiceClient(
handler: RequestHandler
): FreightService {
return {
GetShipper(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.name) {
throw new Error("missing required field request.name");
}
const path = `v1/${request.name}`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "FreightService",
method: "GetShipper",
}) as Promise<Shipper>;
},
ListShippers(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `v1/shippers`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
if (request.pageSize) {
queryParams.push(`pageSize=${encodeURIComponent(request.pageSize.toString())}`)
}
if (request.pageToken) {
queryParams.push(`pageToken=${encodeURIComponent(request.pageToken.toString())}`)
}
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "FreightService",
method: "ListShippers",
}) as Promise<ListShippersResponse>;
},
CreateShipper(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `v1/shippers`; // eslint-disable-line quotes
const body = JSON.stringify(request?.shipper ?? {});
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "FreightService",
method: "CreateShipper",
}) as Promise<Shipper>;
},
UpdateShipper(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.shipper?.name) {
throw new Error("missing required field request.shipper.name");
}
const path = `v1/${request.shipper.name}`; // eslint-disable-line quotes
const body = JSON.stringify(request?.shipper ?? {});
const queryParams: string[] = [];
if (request.updateMask) {
queryParams.push(`updateMask=${encodeURIComponent(request.updateMask.toString())}`)
}
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "PATCH",
body,
}, {
service: "FreightService",
method: "UpdateShipper",
}) as Promise<Shipper>;
},
DeleteShipper(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.name) {
throw new Error("missing required field request.name");
}
const path = `v1/${request.name}`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "DELETE",
body,
}, {
service: "FreightService",
method: "DeleteShipper",
}) as Promise<Shipper>;
},
GetSite(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.name) {
throw new Error("missing required field request.name");
}
const path = `v1/${request.name}`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "FreightService",
method: "GetSite",
}) as Promise<Site>;
},
ListSites(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.parent) {
throw new Error("missing required field request.parent");
}
const path = `v1/${request.parent}/sites`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
if (request.pageSize) {
queryParams.push(`pageSize=${encodeURIComponent(request.pageSize.toString())}`)
}
if (request.pageToken) {
queryParams.push(`pageToken=${encodeURIComponent(request.pageToken.toString())}`)
}
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "FreightService",
method: "ListSites",
}) as Promise<ListSitesResponse>;
},
CreateSite(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.parent) {
throw new Error("missing required field request.parent");
}
const path = `v1/${request.parent}/sites`; // eslint-disable-line quotes
const body = JSON.stringify(request?.site ?? {});
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "FreightService",
method: "CreateSite",
}) as Promise<Site>;
},
UpdateSite(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.site?.name) {
throw new Error("missing required field request.site.name");
}
const path = `v1/${request.site.name}`; // eslint-disable-line quotes
const body = JSON.stringify(request?.site ?? {});
const queryParams: string[] = [];
if (request.updateMask) {
queryParams.push(`updateMask=${encodeURIComponent(request.updateMask.toString())}`)
}
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "PATCH",
body,
}, {
service: "FreightService",
method: "UpdateSite",
}) as Promise<Site>;
},
DeleteSite(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.name) {
throw new Error("missing required field request.name");
}
const path = `v1/${request.name}`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "DELETE",
body,
}, {
service: "FreightService",
method: "DeleteSite",
}) as Promise<Site>;
},
GetShipment(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.name) {
throw new Error("missing required field request.name");
}
const path = `v1/${request.name}`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "FreightService",
method: "GetShipment",
}) as Promise<Shipment>;
},
ListShipments(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.parent) {
throw new Error("missing required field request.parent");
}
const path = `v1/${request.parent}/shipments`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
if (request.pageSize) {
queryParams.push(`pageSize=${encodeURIComponent(request.pageSize.toString())}`)
}
if (request.pageToken) {
queryParams.push(`pageToken=${encodeURIComponent(request.pageToken.toString())}`)
}
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "FreightService",
method: "ListShipments",
}) as Promise<ListShipmentsResponse>;
},
CreateShipment(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.parent) {
throw new Error("missing required field request.parent");
}
const path = `v1/${request.parent}/shipments`; // eslint-disable-line quotes
const body = JSON.stringify(request?.shipment ?? {});
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "FreightService",
method: "CreateShipment",
}) as Promise<Shipment>;
},
UpdateShipment(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.shipment?.name) {
throw new Error("missing required field request.shipment.name");
}
const path = `v1/${request.shipment.name}`; // eslint-disable-line quotes
const body = JSON.stringify(request?.shipment ?? {});
const queryParams: string[] = [];
if (request.updateMask) {
queryParams.push(`updateMask=${encodeURIComponent(request.updateMask.toString())}`)
}
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "PATCH",
body,
}, {
service: "FreightService",
method: "UpdateShipment",
}) as Promise<Shipment>;
},
DeleteShipment(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.name) {
throw new Error("missing required field request.name");
}
const path = `v1/${request.name}`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "DELETE",
body,
}, {
service: "FreightService",
method: "DeleteShipment",
}) as Promise<Shipment>;
},
};
}
// @@protoc_insertion_point(typescript-http-eof)

View File

@@ -0,0 +1,457 @@
// Code generated by protoc-gen-typescript-http. DO NOT EDIT.
/* eslint-disable camelcase */
// @ts-nocheck
// Enum
export type Enum =
// ENUM_UNSPECIFIED
| "ENUM_UNSPECIFIED"
// ENUM_ONE
| "ENUM_ONE"
// ENUM_TWO
| "ENUM_TWO";
// Message
export type Message = {
// double
double: number | undefined;
// float
float: number | undefined;
// int32
int32: number | undefined;
// int64
int64: number | undefined;
// uint32
uint32: number | undefined;
// uint64
uint64: number | undefined;
// sint32
sint32: number | undefined;
// sint64
sint64: number | undefined;
// fixed32
fixed32: number | undefined;
// fixed64
fixed64: number | undefined;
// sfixed32
sfixed32: number | undefined;
// sfixed64
sfixed64: number | undefined;
// bool
bool: boolean | undefined;
// string
string: string | undefined;
// bytes
bytes: string | undefined;
// enum
enum: Enum | undefined;
// message
message: Message | undefined;
// optional double
optionalDouble?: number;
// optional float
optionalFloat?: number;
// optional int32
optionalInt32?: number;
// optional int64
optionalInt64?: number;
// optional uint32
optionalUint32?: number;
// optional uint64
optionalUint64?: number;
// optional sint32
optionalSint32?: number;
// optional sint64
optionalSint64?: number;
// optional fixed32
optionalFixed32?: number;
// optional fixed64
optionalFixed64?: number;
// optional sfixed32
optionalSfixed32?: number;
// optional sfixed64
optionalSfixed64?: number;
// optional bool
optionalBool?: boolean;
// optional string
optionalString?: string;
// optional bytes
optionalBytes?: string;
// optional enum
optionalEnum?: Enum;
// optional message
optionalMessage?: Message;
// repeated_double
repeatedDouble: number[] | undefined;
// repeated_float
repeatedFloat: number[] | undefined;
// repeated_int32
repeatedInt32: number[] | undefined;
// repeated_int64
repeatedInt64: number[] | undefined;
// repeated_uint32
repeatedUint32: number[] | undefined;
// repeated_uint64
repeatedUint64: number[] | undefined;
// repeated_sint32
repeatedSint32: number[] | undefined;
// repeated_sint64
repeatedSint64: number[] | undefined;
// repeated_fixed32
repeatedFixed32: number[] | undefined;
// repeated_fixed64
repeatedFixed64: number[] | undefined;
// repeated_sfixed32
repeatedSfixed32: number[] | undefined;
// repeated_sfixed64
repeatedSfixed64: number[] | undefined;
// repeated_bool
repeatedBool: boolean[] | undefined;
// repeated_string
repeatedString: string[] | undefined;
// repeated_bytes
repeatedBytes: string[] | undefined;
// repeated_enum
repeatedEnum: Enum[] | undefined;
// repeated_message
repeatedMessage: Message[] | undefined;
// map_string_string
mapStringString: { [key: string]: string } | undefined;
// map_string_message
mapStringMessage: { [key: string]: Message } | undefined;
// oneof_string
oneofString?: string;
// oneof_enum
oneofEnum?: Enum;
// oneof_message1
oneofMessage1?: Message;
// oneof_message2
oneofMessage2?: Message;
// any
any: wellKnownAny | undefined;
// repeated_any
repeatedAny: wellKnownAny[] | undefined;
// duration
duration: wellKnownDuration | undefined;
// repeated_duration
repeatedDuration: wellKnownDuration[] | undefined;
// empty
empty: wellKnownEmpty | undefined;
// repeated_empty
repeatedEmpty: wellKnownEmpty[] | undefined;
// field_mask
fieldMask: wellKnownFieldMask | undefined;
// repeated_field_mask
repeatedFieldMask: wellKnownFieldMask[] | undefined;
// struct
struct: wellKnownStruct | undefined;
// repeated_struct
repeatedStruct: wellKnownStruct[] | undefined;
// value
value: wellKnownValue | undefined;
// repeated_value
repeatedValue: wellKnownValue[] | undefined;
// null_value
nullValue: wellKnownNullValue | undefined;
// repeated_null_value
repeatedNullValue: wellKnownNullValue[] | undefined;
// list_value
listValue: wellKnownListValue | undefined;
// repeated_list_value
repeatedListValue: wellKnownListValue[] | undefined;
// bool_value
boolValue: wellKnownBoolValue | undefined;
// repeated_bool_value
repeatedBoolValue: wellKnownBoolValue[] | undefined;
// bytes_value
bytesValue: wellKnownBytesValue | undefined;
// repeated_bytes_value
repeatedBytesValue: wellKnownBytesValue[] | undefined;
// double_value
doubleValue: wellKnownDoubleValue | undefined;
// repeated_double_value
repeatedDoubleValue: wellKnownDoubleValue[] | undefined;
// float_value
floatValue: wellKnownFloatValue | undefined;
// repeated_float_value
repeatedFloatValue: wellKnownFloatValue[] | undefined;
// int32_value
int32Value: wellKnownInt32Value | undefined;
// repeated_int32_value
repeatedInt32Value: wellKnownInt32Value[] | undefined;
// int64_value
int64Value: wellKnownInt64Value | undefined;
// repeated_int64_value
repeatedInt64Value: wellKnownInt64Value[] | undefined;
// uint32_value
uint32Value: wellKnownUInt32Value | undefined;
// repeated_uint32_value
repeatedUint32Value: wellKnownUInt32Value[] | undefined;
// uint64_value
uint64Value: wellKnownUInt64Value | undefined;
// repeated_uint64_value
repeatedUint64Value: wellKnownUInt64Value[] | undefined;
// string_value
stringValue: wellKnownUInt64Value | undefined;
// repeated_string_value
repeatedStringValue: wellKnownStringValue[] | undefined;
};
// If the Any contains a value that has a special JSON mapping,
// it will be converted as follows:
// {"@type": xxx, "value": yyy}.
// Otherwise, the value will be converted into a JSON object,
// and the "@type" field will be inserted to indicate the actual data type.
interface wellKnownAny {
"@type": string;
[key: string]: unknown;
}
// Generated output always contains 0, 3, 6, or 9 fractional digits,
// depending on required precision, followed by the suffix "s".
// Accepted are any fractional digits (also none) as long as they fit
// into nano-seconds precision and the suffix "s" is required.
type wellKnownDuration = string;
// An empty JSON object
type wellKnownEmpty = Record<never, never>;
// In JSON, a field mask is encoded as a single string where paths are
// separated by a comma. Fields name in each path are converted
// to/from lower-camel naming conventions.
// As an example, consider the following message declarations:
//
// message Profile {
// User user = 1;
// Photo photo = 2;
// }
// message User {
// string display_name = 1;
// string address = 2;
// }
//
// In proto a field mask for `Profile` may look as such:
//
// mask {
// paths: "user.display_name"
// paths: "photo"
// }
//
// In JSON, the same mask is represented as below:
//
// {
// mask: "user.displayName,photo"
// }
type wellKnownFieldMask = string;
// Any JSON value.
type wellKnownStruct = Record<string, unknown>;
type wellKnownValue = unknown;
type wellKnownNullValue = null;
type wellKnownListValue = wellKnownValue[];
type wellKnownBoolValue = boolean | null;
type wellKnownBytesValue = string | null;
type wellKnownDoubleValue = number | null;
type wellKnownFloatValue = number | null;
type wellKnownInt32Value = number | null;
type wellKnownInt64Value = number | null;
type wellKnownUInt32Value = number | null;
type wellKnownUInt64Value = number | null;
type wellKnownStringValue = string | null;
// NestedMessage
export type Message_NestedMessage = {
// nested_message.string
string: string | undefined;
};
// NestedEnum
export type Message_NestedEnum =
// NESTEDENUM_UNSPECIFIED
"NESTEDENUM_UNSPECIFIED";
export type Request = {
string: string | undefined;
repeatedString: string[] | undefined;
nested: Request_Nested | undefined;
};
export type Request_Nested = {
string: string | undefined;
};
export interface SyntaxService {
QueryOnly(request: Request): Promise<Message>;
EmptyVerb(request: wellKnownEmpty): Promise<wellKnownEmpty>;
StarBody(request: Request): Promise<Message>;
Body(request: Request): Promise<Message>;
Path(request: Request): Promise<Message>;
PathBody(request: Request): Promise<Message>;
}
type RequestType = {
path: string;
method: string;
body: string | null;
};
type RequestHandler = (request: RequestType, meta: { service: string, method: string }) => Promise<unknown>;
export function createSyntaxServiceClient(
handler: RequestHandler
): SyntaxService {
return {
QueryOnly(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `v1`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
if (request.string) {
queryParams.push(`string=${encodeURIComponent(request.string.toString())}`)
}
if (request.repeatedString) {
request.repeatedString.forEach((x) => {
queryParams.push(`repeatedString=${encodeURIComponent(x.toString())}`)
})
}
if (request.nested?.string) {
queryParams.push(`nested.string=${encodeURIComponent(request.nested.string.toString())}`)
}
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "SyntaxService",
method: "QueryOnly",
}) as Promise<Message>;
},
EmptyVerb(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `v1:emptyVerb`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "SyntaxService",
method: "EmptyVerb",
}) as Promise<wellKnownEmpty>;
},
StarBody(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `v1:starBody`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "SyntaxService",
method: "StarBody",
}) as Promise<Message>;
},
Body(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `v1:body`; // eslint-disable-line quotes
const body = JSON.stringify(request?.nested ?? {});
const queryParams: string[] = [];
if (request.string) {
queryParams.push(`string=${encodeURIComponent(request.string.toString())}`)
}
if (request.repeatedString) {
request.repeatedString.forEach((x) => {
queryParams.push(`repeatedString=${encodeURIComponent(x.toString())}`)
})
}
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "SyntaxService",
method: "Body",
}) as Promise<Message>;
},
Path(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.string) {
throw new Error("missing required field request.string");
}
const path = `v1/${request.string}:path`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
if (request.repeatedString) {
request.repeatedString.forEach((x) => {
queryParams.push(`repeatedString=${encodeURIComponent(x.toString())}`)
})
}
if (request.nested?.string) {
queryParams.push(`nested.string=${encodeURIComponent(request.nested.string.toString())}`)
}
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "SyntaxService",
method: "Path",
}) as Promise<Message>;
},
PathBody(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.string) {
throw new Error("missing required field request.string");
}
const path = `v1/${request.string}:pathBody`; // eslint-disable-line quotes
const body = JSON.stringify(request?.nested ?? {});
const queryParams: string[] = [];
if (request.repeatedString) {
request.repeatedString.forEach((x) => {
queryParams.push(`repeatedString=${encodeURIComponent(x.toString())}`)
})
}
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "SyntaxService",
method: "PathBody",
}) as Promise<Message>;
},
};
}
// @@protoc_insertion_point(typescript-http-eof)

View File

@@ -0,0 +1,290 @@
// Code generated by protoc-gen-typescript-http. DO NOT EDIT.
/* eslint-disable camelcase */
// @ts-nocheck
// Message
export type Message = {
forwardedMessage: einrideexamplesyntaxv1_Message | undefined;
forwardedEnum: einrideexamplesyntaxv1_Enum | undefined;
};
// Message
export type einrideexamplesyntaxv1_Message = {
// double
double: number | undefined;
// float
float: number | undefined;
// int32
int32: number | undefined;
// int64
int64: number | undefined;
// uint32
uint32: number | undefined;
// uint64
uint64: number | undefined;
// sint32
sint32: number | undefined;
// sint64
sint64: number | undefined;
// fixed32
fixed32: number | undefined;
// fixed64
fixed64: number | undefined;
// sfixed32
sfixed32: number | undefined;
// sfixed64
sfixed64: number | undefined;
// bool
bool: boolean | undefined;
// string
string: string | undefined;
// bytes
bytes: string | undefined;
// enum
enum: einrideexamplesyntaxv1_Enum | undefined;
// message
message: einrideexamplesyntaxv1_Message | undefined;
// optional double
optionalDouble?: number;
// optional float
optionalFloat?: number;
// optional int32
optionalInt32?: number;
// optional int64
optionalInt64?: number;
// optional uint32
optionalUint32?: number;
// optional uint64
optionalUint64?: number;
// optional sint32
optionalSint32?: number;
// optional sint64
optionalSint64?: number;
// optional fixed32
optionalFixed32?: number;
// optional fixed64
optionalFixed64?: number;
// optional sfixed32
optionalSfixed32?: number;
// optional sfixed64
optionalSfixed64?: number;
// optional bool
optionalBool?: boolean;
// optional string
optionalString?: string;
// optional bytes
optionalBytes?: string;
// optional enum
optionalEnum?: einrideexamplesyntaxv1_Enum;
// optional message
optionalMessage?: einrideexamplesyntaxv1_Message;
// repeated_double
repeatedDouble: number[] | undefined;
// repeated_float
repeatedFloat: number[] | undefined;
// repeated_int32
repeatedInt32: number[] | undefined;
// repeated_int64
repeatedInt64: number[] | undefined;
// repeated_uint32
repeatedUint32: number[] | undefined;
// repeated_uint64
repeatedUint64: number[] | undefined;
// repeated_sint32
repeatedSint32: number[] | undefined;
// repeated_sint64
repeatedSint64: number[] | undefined;
// repeated_fixed32
repeatedFixed32: number[] | undefined;
// repeated_fixed64
repeatedFixed64: number[] | undefined;
// repeated_sfixed32
repeatedSfixed32: number[] | undefined;
// repeated_sfixed64
repeatedSfixed64: number[] | undefined;
// repeated_bool
repeatedBool: boolean[] | undefined;
// repeated_string
repeatedString: string[] | undefined;
// repeated_bytes
repeatedBytes: string[] | undefined;
// repeated_enum
repeatedEnum: einrideexamplesyntaxv1_Enum[] | undefined;
// repeated_message
repeatedMessage: einrideexamplesyntaxv1_Message[] | undefined;
// map_string_string
mapStringString: { [key: string]: string } | undefined;
// map_string_message
mapStringMessage: { [key: string]: einrideexamplesyntaxv1_Message } | undefined;
// oneof_string
oneofString?: string;
// oneof_enum
oneofEnum?: einrideexamplesyntaxv1_Enum;
// oneof_message1
oneofMessage1?: einrideexamplesyntaxv1_Message;
// oneof_message2
oneofMessage2?: einrideexamplesyntaxv1_Message;
// any
any: wellKnownAny | undefined;
// repeated_any
repeatedAny: wellKnownAny[] | undefined;
// duration
duration: wellKnownDuration | undefined;
// repeated_duration
repeatedDuration: wellKnownDuration[] | undefined;
// empty
empty: wellKnownEmpty | undefined;
// repeated_empty
repeatedEmpty: wellKnownEmpty[] | undefined;
// field_mask
fieldMask: wellKnownFieldMask | undefined;
// repeated_field_mask
repeatedFieldMask: wellKnownFieldMask[] | undefined;
// struct
struct: wellKnownStruct | undefined;
// repeated_struct
repeatedStruct: wellKnownStruct[] | undefined;
// value
value: wellKnownValue | undefined;
// repeated_value
repeatedValue: wellKnownValue[] | undefined;
// null_value
nullValue: wellKnownNullValue | undefined;
// repeated_null_value
repeatedNullValue: wellKnownNullValue[] | undefined;
// list_value
listValue: wellKnownListValue | undefined;
// repeated_list_value
repeatedListValue: wellKnownListValue[] | undefined;
// bool_value
boolValue: wellKnownBoolValue | undefined;
// repeated_bool_value
repeatedBoolValue: wellKnownBoolValue[] | undefined;
// bytes_value
bytesValue: wellKnownBytesValue | undefined;
// repeated_bytes_value
repeatedBytesValue: wellKnownBytesValue[] | undefined;
// double_value
doubleValue: wellKnownDoubleValue | undefined;
// repeated_double_value
repeatedDoubleValue: wellKnownDoubleValue[] | undefined;
// float_value
floatValue: wellKnownFloatValue | undefined;
// repeated_float_value
repeatedFloatValue: wellKnownFloatValue[] | undefined;
// int32_value
int32Value: wellKnownInt32Value | undefined;
// repeated_int32_value
repeatedInt32Value: wellKnownInt32Value[] | undefined;
// int64_value
int64Value: wellKnownInt64Value | undefined;
// repeated_int64_value
repeatedInt64Value: wellKnownInt64Value[] | undefined;
// uint32_value
uint32Value: wellKnownUInt32Value | undefined;
// repeated_uint32_value
repeatedUint32Value: wellKnownUInt32Value[] | undefined;
// uint64_value
uint64Value: wellKnownUInt64Value | undefined;
// repeated_uint64_value
repeatedUint64Value: wellKnownUInt64Value[] | undefined;
// string_value
stringValue: wellKnownUInt64Value | undefined;
// repeated_string_value
repeatedStringValue: wellKnownStringValue[] | undefined;
};
// Enum
export type einrideexamplesyntaxv1_Enum =
// ENUM_UNSPECIFIED
| "ENUM_UNSPECIFIED"
// ENUM_ONE
| "ENUM_ONE"
// ENUM_TWO
| "ENUM_TWO";
// If the Any contains a value that has a special JSON mapping,
// it will be converted as follows:
// {"@type": xxx, "value": yyy}.
// Otherwise, the value will be converted into a JSON object,
// and the "@type" field will be inserted to indicate the actual data type.
interface wellKnownAny {
"@type": string;
[key: string]: unknown;
}
// Generated output always contains 0, 3, 6, or 9 fractional digits,
// depending on required precision, followed by the suffix "s".
// Accepted are any fractional digits (also none) as long as they fit
// into nano-seconds precision and the suffix "s" is required.
type wellKnownDuration = string;
// An empty JSON object
type wellKnownEmpty = Record<never, never>;
// In JSON, a field mask is encoded as a single string where paths are
// separated by a comma. Fields name in each path are converted
// to/from lower-camel naming conventions.
// As an example, consider the following message declarations:
//
// message Profile {
// User user = 1;
// Photo photo = 2;
// }
// message User {
// string display_name = 1;
// string address = 2;
// }
//
// In proto a field mask for `Profile` may look as such:
//
// mask {
// paths: "user.display_name"
// paths: "photo"
// }
//
// In JSON, the same mask is represented as below:
//
// {
// mask: "user.displayName,photo"
// }
type wellKnownFieldMask = string;
// Any JSON value.
type wellKnownStruct = Record<string, unknown>;
type wellKnownValue = unknown;
type wellKnownNullValue = null;
type wellKnownListValue = wellKnownValue[];
type wellKnownBoolValue = boolean | null;
type wellKnownBytesValue = string | null;
type wellKnownDoubleValue = number | null;
type wellKnownFloatValue = number | null;
type wellKnownInt32Value = number | null;
type wellKnownInt64Value = number | null;
type wellKnownUInt32Value = number | null;
type wellKnownUInt64Value = number | null;
type wellKnownStringValue = string | null;
// NestedMessage
export type einrideexamplesyntaxv1_Message_NestedMessage = {
// nested_message.string
string: string | undefined;
};
// NestedEnum
export type einrideexamplesyntaxv1_Message_NestedEnum =
// NESTEDENUM_UNSPECIFIED
"NESTEDENUM_UNSPECIFIED";
// @@protoc_insertion_point(typescript-http-eof)