Skip to content

Commit

Permalink
fix: improvements to protobuf-es-lite
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed Apr 26, 2024
1 parent 66b8c5c commit c035d06
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 56 deletions.
12 changes: 6 additions & 6 deletions example/example.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions example/example_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createMessageType,
Message,
MessageType,
PartialFieldInfo,
} from '@aptre/protobuf-es-lite'

export const protobufPackage = 'example'
Expand All @@ -19,13 +20,13 @@ export interface EchoMsg extends Message<EchoMsg> {
/**
* @generated from field: string body = 1;
*/
body: string
body?: string
}

export const EchoMsg: MessageType<EchoMsg> = createMessageType({
typeName: 'example.EchoMsg',
fields: [
{ no: 1, name: 'body', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
],
] as readonly PartialFieldInfo[],
packedByDefault: true,
})
2 changes: 1 addition & 1 deletion example/example_srpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions example/example_srpc.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/* eslint-disable */

import { EchoMsg } from './example_pb.js'
import type { PartialMessage } from '@bufbuild/protobuf'
import { MethodKind } from '@bufbuild/protobuf'
import { Message } from '@aptre/protobuf-es-lite'
import {
buildDecodeMessageTransform,
buildEncodeMessageTransform,
Expand Down Expand Up @@ -79,17 +79,17 @@ export interface Echoer {
* @generated from rpc example.Echoer.Echo
*/
Echo(
request: PartialMessage<EchoMsg>,
request: Message<EchoMsg>,
abortSignal?: AbortSignal,
): Promise<PartialMessage<EchoMsg>>
): Promise<Message<EchoMsg>>

/**
* EchoServerStream is an example of a server -> client one-way stream.
*
* @generated from rpc example.Echoer.EchoServerStream
*/
EchoServerStream(
request: PartialMessage<EchoMsg>,
request: Message<EchoMsg>,
abortSignal?: AbortSignal,
): MessageStream<EchoMsg>

Expand All @@ -101,7 +101,7 @@ export interface Echoer {
EchoClientStream(
request: MessageStream<EchoMsg>,
abortSignal?: AbortSignal,
): Promise<PartialMessage<EchoMsg>>
): Promise<Message<EchoMsg>>

/**
* EchoBidiStream is an example of a two-way stream.
Expand Down Expand Up @@ -133,14 +133,14 @@ export class EchoerClient implements Echoer {
* @generated from rpc example.Echoer.Echo
*/
async Echo(
request: PartialMessage<EchoMsg>,
request: Message<EchoMsg>,
abortSignal?: AbortSignal,
): Promise<PartialMessage<EchoMsg>> {
const requestMsg = new EchoMsg(request)
): Promise<Message<EchoMsg>> {
const requestMsg = EchoMsg.create(request)
const result = await this.rpc.request(
this.service,
EchoerDefinition.methods.Echo.name,
requestMsg.toBinary(),
EchoMsg.toBinary(requestMsg),
abortSignal || undefined,
)
return EchoMsg.fromBinary(result)
Expand All @@ -152,14 +152,14 @@ export class EchoerClient implements Echoer {
* @generated from rpc example.Echoer.EchoServerStream
*/
EchoServerStream(
request: PartialMessage<EchoMsg>,
request: Message<EchoMsg>,
abortSignal?: AbortSignal,
): MessageStream<EchoMsg> {
const requestMsg = new EchoMsg(request)
const requestMsg = EchoMsg.create(request)
const result = this.rpc.serverStreamingRequest(
this.service,
EchoerDefinition.methods.EchoServerStream.name,
requestMsg.toBinary(),
EchoMsg.toBinary(requestMsg),
abortSignal || undefined,
)
return buildDecodeMessageTransform(EchoMsg)(result)
Expand All @@ -173,7 +173,7 @@ export class EchoerClient implements Echoer {
async EchoClientStream(
request: MessageStream<EchoMsg>,
abortSignal?: AbortSignal,
): Promise<PartialMessage<EchoMsg>> {
): Promise<Message<EchoMsg>> {
const result = await this.rpc.clientStreamingRequest(
this.service,
EchoerDefinition.methods.EchoClientStream.name,
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/aperturerobotics/template
go 1.22

require (
github.com/aperturerobotics/common v0.14.0 // latest
github.com/aperturerobotics/common v0.14.1 // latest
github.com/aperturerobotics/protobuf-go-lite v0.6.0 // latest
github.com/aperturerobotics/starpc v0.31.3 // latest
)

require github.com/pkg/errors v0.9.1
require github.com/pkg/errors v0.9.1 // indirect

require (
github.com/aperturerobotics/json-iterator-lite v1.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/aperturerobotics/common v0.14.0 h1:aq6eintARDDGREB34uPogmnhO6U/61d8le3FU+P/qac=
github.com/aperturerobotics/common v0.14.0/go.mod h1:MkCLl9iUXglujvO9wAbrZ9bm72mesXaAq288HGnzshA=
github.com/aperturerobotics/common v0.14.1 h1:QmXrsCLp6r5HiKXES0VM5NelSw6Ga5Gr983dGiE1hy4=
github.com/aperturerobotics/common v0.14.1/go.mod h1:MkCLl9iUXglujvO9wAbrZ9bm72mesXaAq288HGnzshA=
github.com/aperturerobotics/json-iterator-lite v1.0.0 h1:cihbrYWoK/S2RYXhJLpDZd+GUjVvFJN+D3w1VOqqHRI=
github.com/aperturerobotics/json-iterator-lite v1.0.0/go.mod h1:snaApCEDtrHHP6UWSLKiYNOZU9A5NyzccKenx9oZEzg=
github.com/aperturerobotics/protobuf-go-lite v0.6.0 h1:EE168e2oov6wmDv8AdSAlz2G1nHbf0HlYG917CgJ+ug=
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
"singleQuote": true
},
"devDependencies": {
"@aptre/common": "^0.14.0",
"@aptre/common": "^0.14.1",
"depcheck": "^1.4.7",
"prettier": "^3.2.5",
"typescript": "^5.1.6"
},
"dependencies": {
"@aptre/protobuf-es-lite": "^0.1.2",
"@aptre/protobuf-es-lite": "^0.2.3",
"@bufbuild/protobuf": "^1.9.0",
"starpc": "^0.31.6"
"starpc": "^0.31.7"
}
}
78 changes: 51 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf"
integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==

"@aptre/common@^0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@aptre/common/-/common-0.14.0.tgz#f50cd328f006da3cde45ceaa38ed5243b82660ca"
integrity sha512-0OSKBaXTsz/X87UOTrqB7I0iBNZZ5V4nhlbCum0t3FsSSKzFGIlFOsytxBGefi5kCXNy+3/dxta1tdymuQOdvw==
"@aptre/common@^0.14.1":
version "0.14.1"
resolved "https://registry.yarnpkg.com/@aptre/common/-/common-0.14.1.tgz#b73fbfb58f43478b072bda52ccac0371b17222d8"
integrity sha512-xVoNBCIpjbJr+SwfOwYN4B/H3wI+hdrOgPnCfKmiSQg0YO5JOctQMXWvCAwxukDSSiJf8jrhd/3bsWG+fN6KPg==
dependencies:
"@aptre/protobuf-es-lite" "^0.1.2"
"@aptre/protobuf-es-lite" "^0.2.3"
"@bufbuild/protobuf" "^1.8.0"
"@typescript-eslint/eslint-plugin" "^7.7.0"
"@typescript-eslint/parser" "^7.7.0"
eslint "^9.1.0"
eslint-config-prettier "^9.0.0"
eslint-plugin-react-hooks "^4.6.0"
eslint-plugin-react-hooks "^4.6.1"
eslint-plugin-unused-imports "^3.0.0"
starpc "^0.31.6"
starpc "^0.31.7"

"@aptre/it-ws@^1.0.0":
version "1.0.0"
Expand All @@ -33,10 +33,10 @@
uint8arrays "^5.0.0"
ws "^8.4.0"

"@aptre/protobuf-es-lite@^0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@aptre/protobuf-es-lite/-/protobuf-es-lite-0.1.2.tgz#f9029c460850983b31b4bc1b1bd7fa4d0dbada20"
integrity sha512-0kphczr7jOjpUnv8CbRIAj6jK9y4iZvYAN0iwxywrD8GmDpF4NEaLpx7r1x5u5hmq/TcAeBnDzxLh08w766/MQ==
"@aptre/protobuf-es-lite@^0.2.3":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@aptre/protobuf-es-lite/-/protobuf-es-lite-0.2.3.tgz#f3347985cad9861819fd3642afa28d408c7bf9b7"
integrity sha512-pJnQDAPO2UdQgezm8wukxIMvxq5ZD8hqnZh5sHDKKDfFHgqT8IsNmDaUxprNzuQee7ayPmtPcm1pO99XwJP8hg==
dependencies:
"@bufbuild/protobuf" "^1.9.0"
"@bufbuild/protoplugin" "1.9.0"
Expand Down Expand Up @@ -289,7 +289,19 @@
progress-events "^1.0.0"
uint8arraylist "^2.4.8"

"@libp2p/logger@^4.0.10", "@libp2p/logger@^4.0.6":
"@libp2p/interface@^1.3.0":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@libp2p/interface/-/interface-1.3.0.tgz#c4fcee2878aa8d37357974b6c7395cb2a645eb50"
integrity sha512-K72Km0Co1Z+pXpggWuoAvUUbvwZYvjCcywrHj2Ym3jt2anTE3hzL4rlZrrkzA0YhNTRFRiZ04dnu6WMXT5/4+A==
dependencies:
"@multiformats/multiaddr" "^12.2.1"
it-pushable "^3.2.3"
it-stream-types "^2.0.1"
multiformats "^13.1.0"
progress-events "^1.0.0"
uint8arraylist "^2.4.8"

"@libp2p/logger@^4.0.10":
version "4.0.10"
resolved "https://registry.yarnpkg.com/@libp2p/logger/-/logger-4.0.10.tgz#d59db10d74b20e78be37f8ec53c1139174c0afda"
integrity sha512-JiRfJHO/D9Jlh2rJ6STnONoeQevBAdAZaGUxrtvBf4RFfucldSFEMOtdkFO8xFGuiA90Q2kj4BE2douG6fB3Lw==
Expand All @@ -300,6 +312,17 @@
interface-datastore "^8.2.11"
multiformats "^13.1.0"

"@libp2p/logger@^4.0.11":
version "4.0.11"
resolved "https://registry.yarnpkg.com/@libp2p/logger/-/logger-4.0.11.tgz#671692a0cceee73a0c0bf9b5f05ea14fde05f5e5"
integrity sha512-WsZBup1Q+ec4C7i2YiCx0elFrejqJea3Fmkzy3t4fAek7Ofyh4GQonk3A4R7XsG5yq8+Hu1fpsGhIK8EVQsqZQ==
dependencies:
"@libp2p/interface" "^1.3.0"
"@multiformats/multiaddr" "^12.2.1"
debug "^4.3.4"
interface-datastore "^8.2.11"
multiformats "^13.1.0"

"@libp2p/utils@^5.2.5":
version "5.3.1"
resolved "https://registry.yarnpkg.com/@libp2p/utils/-/utils-5.3.1.tgz#1d3ff7e494f78503f33e1c8df4ad4a13209d594b"
Expand Down Expand Up @@ -861,10 +884,10 @@ eslint-config-prettier@^9.0.0:
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f"
integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==

eslint-plugin-react-hooks@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3"
integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==
eslint-plugin-react-hooks@^4.6.1:
version "4.6.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.1.tgz#85a7e271da14ae4eb4ed717abb4db6e99700550f"
integrity sha512-Ck77j8hF7l9N4S/rzSLOWEKpn994YH6iwUK8fr9mXIaQvGpQYmOnQLbiue1u5kI5T1y+gdgqosnEAO9NCz0DBg==

eslint-plugin-unused-imports@^3.0.0:
version "3.1.0"
Expand Down Expand Up @@ -1279,10 +1302,10 @@ isomorphic-ws@^5.0.0:
resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz#e5529148912ecb9b451b46ed44d53dae1ce04bbf"
integrity sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==

it-first@^3.0.3:
version "3.0.4"
resolved "https://registry.yarnpkg.com/it-first/-/it-first-3.0.4.tgz#d68c8ae646ea402cd5e650c352da69988a310342"
integrity sha512-FtQl84iTNxN5EItP/JgL28V2rzNMkCzTUlNoj41eVdfix2z1DBuLnBqZ0hzYhGGa1rMpbQf0M7CQSA2adlrLJg==
it-first@^3.0.6:
version "3.0.6"
resolved "https://registry.yarnpkg.com/it-first/-/it-first-3.0.6.tgz#f532f0f36fe9bf0c291e0162b9d3375d59fe8f05"
integrity sha512-ExIewyK9kXKNAplg2GMeWfgjUcfC1FnUXz/RPfAvIXby+w7U4b3//5Lic0NV03gXT8O/isj5Nmp6KiY0d45pIQ==

it-foreach@^2.0.6:
version "2.0.6"
Expand Down Expand Up @@ -1742,19 +1765,20 @@ sprintf-js@~1.0.2:
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==

starpc@^0.31.6:
version "0.31.6"
resolved "https://registry.yarnpkg.com/starpc/-/starpc-0.31.6.tgz#c183e7ec8a68f06c306be44885c7a6c4c1ca4651"
integrity sha512-9GnZZdvYQBZhOHptMKI3TKFHRoC1y9tHvZntLujMTyRnnvtOrD+Ss+IV3ue8jyv36MITDS+oEpo7O0IAaWNdlw==
starpc@^0.31.7:
version "0.31.7"
resolved "https://registry.yarnpkg.com/starpc/-/starpc-0.31.7.tgz#fef7b5476e05b8119f751b165b72f49bf57ab97b"
integrity sha512-RQMwInbJ/QTj6FGb+70D1lafGTQhKFgDNc4ATwwIwILkHH5o8JESfkZGZ+wUAgIA5pPY1HqVC/zjXyLIcp07Iw==
dependencies:
"@aptre/it-ws" "^1.0.0"
"@aptre/protobuf-es-lite" "^0.2.3"
"@bufbuild/protoplugin" "^1.9.0"
"@chainsafe/libp2p-yamux" "^6.0.2"
"@libp2p/interface" "^1.1.3"
"@libp2p/logger" "^4.0.6"
"@libp2p/interface" "^1.3.0"
"@libp2p/logger" "^4.0.11"
event-iterator "^2.0.0"
isomorphic-ws "^5.0.0"
it-first "^3.0.3"
it-first "^3.0.6"
it-pipe "^3.0.1"
it-pushable "^3.2.3"
it-stream-types "^2.0.1"
Expand Down

0 comments on commit c035d06

Please sign in to comment.