Skip to content

Commit

Permalink
fix: regenerate protobuf messages
Browse files Browse the repository at this point in the history
Updates to the latest protons message format.
  • Loading branch information
achingbrain committed Aug 8, 2024
1 parent 408f103 commit dd88be1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
15 changes: 8 additions & 7 deletions packages/it-protobuf-stream/test/fixtures/test-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */

import { encodeMessage, decodeMessage, message } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, message } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'

export interface TestMessage {
Expand All @@ -30,7 +29,7 @@ export namespace TestMessage {
if (opts.lengthDelimited !== false) {
w.ldelim()
}
}, (reader, length) => {
}, (reader, length, opts = {}) => {
const obj: any = {
foo: ''
}
Expand All @@ -41,12 +40,14 @@ export namespace TestMessage {
const tag = reader.uint32()

switch (tag >>> 3) {
case 1:
case 1: {
obj.foo = reader.string()
break
default:
}
default: {
reader.skipType(tag & 7)
break
}

Check warning on line 50 in packages/it-protobuf-stream/test/fixtures/test-message.ts

View check run for this annotation

Codecov / codecov/patch

packages/it-protobuf-stream/test/fixtures/test-message.ts#L50

Added line #L50 was not covered by tests
}
}

Expand All @@ -61,7 +62,7 @@ export namespace TestMessage {
return encodeMessage(obj, TestMessage.codec())
}

export const decode = (buf: Uint8Array | Uint8ArrayList): TestMessage => {
return decodeMessage(buf, TestMessage.codec())
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<TestMessage>): TestMessage => {
return decodeMessage(buf, TestMessage.codec(), opts)
}
}
14 changes: 7 additions & 7 deletions packages/it-rpc/src/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
/* eslint-disable @typescript-eslint/no-empty-interface */

import { type Codec, CodeError, decodeMessage, type DecodeOptions, encodeMessage, enumeration, message } from 'protons-runtime'
import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, enumeration, MaxLengthError, message } from 'protons-runtime'
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
import type { Uint8ArrayList } from 'uint8arraylist'

Expand Down Expand Up @@ -237,7 +237,7 @@ export namespace InvokeMethodMessage {
}
case 3: {
if (opts.limits?.args != null && obj.args.length === opts.limits.args) {
throw new CodeError('decode error - map field "args" had too many elements', 'ERR_MAX_LENGTH')
throw new MaxLengthError('Decode error - map field "args" had too many elements')

Check warning on line 240 in packages/it-rpc/src/rpc.ts

View check run for this annotation

Codecov / codecov/patch

packages/it-rpc/src/rpc.ts#L240

Added line #L240 was not covered by tests
}

obj.args.push(Value.codec().decode(reader, reader.uint32(), {
Expand Down Expand Up @@ -536,7 +536,7 @@ export namespace InvokeCallbackMessage {
}
case 2: {
if (opts.limits?.parents != null && obj.parents.length === opts.limits.parents) {
throw new CodeError('decode error - map field "parents" had too many elements', 'ERR_MAX_LENGTH')
throw new MaxLengthError('Decode error - map field "parents" had too many elements')

Check warning on line 539 in packages/it-rpc/src/rpc.ts

View check run for this annotation

Codecov / codecov/patch

packages/it-rpc/src/rpc.ts#L539

Added line #L539 was not covered by tests
}

obj.parents.push(reader.string())
Expand All @@ -548,7 +548,7 @@ export namespace InvokeCallbackMessage {
}
case 4: {
if (opts.limits?.args != null && obj.args.length === opts.limits.args) {
throw new CodeError('decode error - map field "args" had too many elements', 'ERR_MAX_LENGTH')
throw new MaxLengthError('Decode error - map field "args" had too many elements')

Check warning on line 551 in packages/it-rpc/src/rpc.ts

View check run for this annotation

Codecov / codecov/patch

packages/it-rpc/src/rpc.ts#L551

Added line #L551 was not covered by tests
}

obj.args.push(Value.codec().decode(reader, reader.uint32(), {
Expand Down Expand Up @@ -627,7 +627,7 @@ export namespace AbortCallbackMessage {
}
case 2: {
if (opts.limits?.parents != null && obj.parents.length === opts.limits.parents) {
throw new CodeError('decode error - map field "parents" had too many elements', 'ERR_MAX_LENGTH')
throw new MaxLengthError('Decode error - map field "parents" had too many elements')

Check warning on line 630 in packages/it-rpc/src/rpc.ts

View check run for this annotation

Codecov / codecov/patch

packages/it-rpc/src/rpc.ts#L630

Added line #L630 was not covered by tests
}

obj.parents.push(reader.string())
Expand Down Expand Up @@ -710,7 +710,7 @@ export namespace CallbackResolvedMessage {
}
case 2: {
if (opts.limits?.parents != null && obj.parents.length === opts.limits.parents) {
throw new CodeError('decode error - map field "parents" had too many elements', 'ERR_MAX_LENGTH')
throw new MaxLengthError('Decode error - map field "parents" had too many elements')

Check warning on line 713 in packages/it-rpc/src/rpc.ts

View check run for this annotation

Codecov / codecov/patch

packages/it-rpc/src/rpc.ts#L713

Added line #L713 was not covered by tests
}

obj.parents.push(reader.string())
Expand Down Expand Up @@ -799,7 +799,7 @@ export namespace CallbackRejectedMessage {
}
case 2: {
if (opts.limits?.parents != null && obj.parents.length === opts.limits.parents) {
throw new CodeError('decode error - map field "parents" had too many elements', 'ERR_MAX_LENGTH')
throw new MaxLengthError('Decode error - map field "parents" had too many elements')

Check warning on line 802 in packages/it-rpc/src/rpc.ts

View check run for this annotation

Codecov / codecov/patch

packages/it-rpc/src/rpc.ts#L802

Added line #L802 was not covered by tests
}

obj.parents.push(reader.string())
Expand Down

0 comments on commit dd88be1

Please sign in to comment.