diff --git a/packages/bundle-size/README.md b/packages/bundle-size/README.md index 699af2537..de379c6dd 100644 --- a/packages/bundle-size/README.md +++ b/packages/bundle-size/README.md @@ -16,11 +16,11 @@ usually do. We repeat this for an increasing number of files. | code generator | files | bundle size | minified | compressed | |-----------------|----------|------------------------:|-----------------------:|-------------------:| -| protobuf-es | 1 | 123,775 b | 64,241 b | 14,974 b | -| protobuf-es | 4 | 125,970 b | 65,745 b | 15,652 b | -| protobuf-es | 8 | 128,748 b | 67,516 b | 16,179 b | -| protobuf-es | 16 | 139,256 b | 75,497 b | 18,508 b | -| protobuf-es | 32 | 167,151 b | 97,519 b | 23,990 b | +| protobuf-es | 1 | 123,862 b | 64,285 b | 15,000 b | +| protobuf-es | 4 | 126,057 b | 65,789 b | 15,698 b | +| protobuf-es | 8 | 128,835 b | 67,560 b | 16,188 b | +| protobuf-es | 16 | 139,343 b | 75,541 b | 18,515 b | +| protobuf-es | 32 | 167,238 b | 97,563 b | 23,959 b | | protobuf-javascript | 1 | 339,613 b | 255,820 b | 42,481 b | | protobuf-javascript | 4 | 366,281 b | 271,092 b | 43,912 b | | protobuf-javascript | 8 | 388,324 b | 283,409 b | 45,038 b | diff --git a/packages/bundle-size/chart.svg b/packages/bundle-size/chart.svg index 46e1a40ab..64b68c7aa 100644 --- a/packages/bundle-size/chart.svg +++ b/packages/bundle-size/chart.svg @@ -43,14 +43,14 @@ 0 KiB - + protobuf-es -protobuf-es 14.62 KiB for 1 files -protobuf-es 15.29 KiB for 4 files -protobuf-es 15.8 KiB for 8 files -protobuf-es 18.07 KiB for 16 files -protobuf-es 23.43 KiB for 32 files +protobuf-es 14.65 KiB for 1 files +protobuf-es 15.33 KiB for 4 files +protobuf-es 15.81 KiB for 8 files +protobuf-es 18.08 KiB for 16 files +protobuf-es 23.4 KiB for 32 files diff --git a/packages/bundle-size/src/gen/protobuf-es/google/bytestream/bytestream_pb.ts b/packages/bundle-size/src/gen/protobuf-es/google/bytestream/bytestream_pb.ts index 9a12c00ae..97b4d9d94 100644 --- a/packages/bundle-size/src/gen/protobuf-es/google/bytestream/bytestream_pb.ts +++ b/packages/bundle-size/src/gen/protobuf-es/google/bytestream/bytestream_pb.ts @@ -262,9 +262,9 @@ export const ByteStream: GenDescService<{ * @generated from rpc google.bytestream.ByteStream.Read */ read: { - kind: "server_streaming"; - I: typeof ReadRequestDesc; - O: typeof ReadResponseDesc; + methodKind: "server_streaming"; + input: typeof ReadRequestDesc; + output: typeof ReadResponseDesc; }, /** * `Write()` is used to send the contents of a resource as a sequence of @@ -293,9 +293,9 @@ export const ByteStream: GenDescService<{ * @generated from rpc google.bytestream.ByteStream.Write */ write: { - kind: "client_streaming"; - I: typeof WriteRequestDesc; - O: typeof WriteResponseDesc; + methodKind: "client_streaming"; + input: typeof WriteRequestDesc; + output: typeof WriteResponseDesc; }, /** * `QueryWriteStatus()` is used to find the `committed_size` for a resource @@ -316,9 +316,9 @@ export const ByteStream: GenDescService<{ * @generated from rpc google.bytestream.ByteStream.QueryWriteStatus */ queryWriteStatus: { - kind: "unary"; - I: typeof QueryWriteStatusRequestDesc; - O: typeof QueryWriteStatusResponseDesc; + methodKind: "unary"; + input: typeof QueryWriteStatusRequestDesc; + output: typeof QueryWriteStatusResponseDesc; }, } > = /*@__PURE__*/ diff --git a/packages/bundle-size/src/gen/protobuf-es/google/longrunning/operations_pb.ts b/packages/bundle-size/src/gen/protobuf-es/google/longrunning/operations_pb.ts index aa2b1e37e..7af421e94 100644 --- a/packages/bundle-size/src/gen/protobuf-es/google/longrunning/operations_pb.ts +++ b/packages/bundle-size/src/gen/protobuf-es/google/longrunning/operations_pb.ts @@ -350,9 +350,9 @@ export const Operations: GenDescService<{ * @generated from rpc google.longrunning.Operations.ListOperations */ listOperations: { - kind: "unary"; - I: typeof ListOperationsRequestDesc; - O: typeof ListOperationsResponseDesc; + methodKind: "unary"; + input: typeof ListOperationsRequestDesc; + output: typeof ListOperationsResponseDesc; }, /** * Gets the latest state of a long-running operation. Clients can use this @@ -362,9 +362,9 @@ export const Operations: GenDescService<{ * @generated from rpc google.longrunning.Operations.GetOperation */ getOperation: { - kind: "unary"; - I: typeof GetOperationRequestDesc; - O: typeof OperationDesc; + methodKind: "unary"; + input: typeof GetOperationRequestDesc; + output: typeof OperationDesc; }, /** * Deletes a long-running operation. This method indicates that the client is @@ -375,9 +375,9 @@ export const Operations: GenDescService<{ * @generated from rpc google.longrunning.Operations.DeleteOperation */ deleteOperation: { - kind: "unary"; - I: typeof DeleteOperationRequestDesc; - O: typeof EmptyDesc; + methodKind: "unary"; + input: typeof DeleteOperationRequestDesc; + output: typeof EmptyDesc; }, /** * Starts asynchronous cancellation on a long-running operation. The server @@ -394,9 +394,9 @@ export const Operations: GenDescService<{ * @generated from rpc google.longrunning.Operations.CancelOperation */ cancelOperation: { - kind: "unary"; - I: typeof CancelOperationRequestDesc; - O: typeof EmptyDesc; + methodKind: "unary"; + input: typeof CancelOperationRequestDesc; + output: typeof EmptyDesc; }, /** * Waits until the specified long-running operation is done or reaches at most @@ -412,9 +412,9 @@ export const Operations: GenDescService<{ * @generated from rpc google.longrunning.Operations.WaitOperation */ waitOperation: { - kind: "unary"; - I: typeof WaitOperationRequestDesc; - O: typeof OperationDesc; + methodKind: "unary"; + input: typeof WaitOperationRequestDesc; + output: typeof OperationDesc; }, } > = /*@__PURE__*/ diff --git a/packages/protobuf-test/src/gen/js/extra/deprecation-explicit_pb.d.ts b/packages/protobuf-test/src/gen/js/extra/deprecation-explicit_pb.d.ts index 3562b0ddc..5fde82462 100644 --- a/packages/protobuf-test/src/gen/js/extra/deprecation-explicit_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/extra/deprecation-explicit_pb.d.ts @@ -131,9 +131,9 @@ export declare const DeprecatedService: GenDescService<{ * @generated from rpc spec.DeprecatedService.Deprecated */ deprecated: { - kind: "unary"; - I: typeof EmptyDesc; - O: typeof EmptyDesc; + methodKind: "unary"; + input: typeof EmptyDesc; + output: typeof EmptyDesc; }, } >; @@ -149,17 +149,17 @@ export declare const DeprecatedRpcService: GenDescService<{ * @deprecated */ deprecated: { - kind: "unary"; - I: typeof EmptyDesc; - O: typeof EmptyDesc; + methodKind: "unary"; + input: typeof EmptyDesc; + output: typeof EmptyDesc; }, /** * @generated from rpc spec.DeprecatedRpcService.NotDeprecated */ notDeprecated: { - kind: "unary"; - I: typeof EmptyDesc; - O: typeof EmptyDesc; + methodKind: "unary"; + input: typeof EmptyDesc; + output: typeof EmptyDesc; }, } >; diff --git a/packages/protobuf-test/src/gen/js/extra/deprecation-implicit_pb.d.ts b/packages/protobuf-test/src/gen/js/extra/deprecation-implicit_pb.d.ts index f4d278f83..99aa892a4 100644 --- a/packages/protobuf-test/src/gen/js/extra/deprecation-implicit_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/extra/deprecation-implicit_pb.d.ts @@ -70,9 +70,9 @@ export declare const ImplicitlyDeprecatedService: GenDescService<{ * @generated from rpc spec.ImplicitlyDeprecatedService.ImplicitlyDeprecatedRpc */ implicitlyDeprecatedRpc: { - kind: "unary"; - I: typeof EmptyDesc; - O: typeof EmptyDesc; + methodKind: "unary"; + input: typeof EmptyDesc; + output: typeof EmptyDesc; }, } >; diff --git a/packages/protobuf-test/src/gen/js/extra/name-clash_pb.d.ts b/packages/protobuf-test/src/gen/js/extra/name-clash_pb.d.ts index 3e85afed2..7ddbca7fb 100644 --- a/packages/protobuf-test/src/gen/js/extra/name-clash_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/extra/name-clash_pb.d.ts @@ -980,33 +980,33 @@ export declare const ReservedPropertyNamesService: GenDescService<{ * @generated from rpc spec.ReservedPropertyNamesService.constructor */ constructor$: { - kind: "unary"; - I: typeof ErrorDesc; - O: typeof ErrorDesc; + methodKind: "unary"; + input: typeof ErrorDesc; + output: typeof ErrorDesc; }, /** * @generated from rpc spec.ReservedPropertyNamesService.toString */ toString$: { - kind: "unary"; - I: typeof ErrorDesc; - O: typeof ErrorDesc; + methodKind: "unary"; + input: typeof ErrorDesc; + output: typeof ErrorDesc; }, /** * @generated from rpc spec.ReservedPropertyNamesService.to_JSON */ to_JSON: { - kind: "unary"; - I: typeof ErrorDesc; - O: typeof ErrorDesc; + methodKind: "unary"; + input: typeof ErrorDesc; + output: typeof ErrorDesc; }, /** * @generated from rpc spec.ReservedPropertyNamesService.value_of */ value_of: { - kind: "unary"; - I: typeof ErrorDesc; - O: typeof ErrorDesc; + methodKind: "unary"; + input: typeof ErrorDesc; + output: typeof ErrorDesc; }, } >; diff --git a/packages/protobuf-test/src/gen/js/extra/option-usage_pb.d.ts b/packages/protobuf-test/src/gen/js/extra/option-usage_pb.d.ts index 162c0a9d9..ad6fdfb47 100644 --- a/packages/protobuf-test/src/gen/js/extra/option-usage_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/extra/option-usage_pb.d.ts @@ -74,9 +74,9 @@ export declare const ServiceWithOptions: GenDescService<{ * @generated from rpc spec.ServiceWithOptions.Foo */ foo: { - kind: "unary"; - I: typeof MessageWithOptionsDesc; - O: typeof MessageWithOptionsDesc; + methodKind: "unary"; + input: typeof MessageWithOptionsDesc; + output: typeof MessageWithOptionsDesc; }, } >; diff --git a/packages/protobuf-test/src/gen/js/extra/service-all_pb.d.ts b/packages/protobuf-test/src/gen/js/extra/service-all_pb.d.ts index 94c53e970..f064b6223 100644 --- a/packages/protobuf-test/src/gen/js/extra/service-all_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/extra/service-all_pb.d.ts @@ -32,34 +32,34 @@ export declare const ServiceAll: GenDescService<{ * @generated from rpc spec.ServiceAll.Unary */ unary: { - kind: "unary"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "unary"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }, /** * @generated from rpc spec.ServiceAll.ServerStream */ serverStream: { - kind: "server_streaming"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "server_streaming"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }, /** * @generated from rpc spec.ServiceAll.ClientStream */ clientStream: { - kind: "client_streaming"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "client_streaming"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }, /** * @generated from rpc spec.ServiceAll.Bidi * @deprecated */ bidi: { - kind: "bidi_streaming"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "bidi_streaming"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }, } >; diff --git a/packages/protobuf-test/src/gen/js/extra/service-example_pb.d.ts b/packages/protobuf-test/src/gen/js/extra/service-example_pb.d.ts index fb12f06f2..1be7f6cbc 100644 --- a/packages/protobuf-test/src/gen/js/extra/service-example_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/extra/service-example_pb.d.ts @@ -149,33 +149,33 @@ export declare const ExampleService: GenDescService<{ * @generated from rpc spec.ExampleService.Unary */ unary: { - kind: "unary"; - I: typeof ExampleRequestDesc; - O: typeof ExampleResponseDesc; + methodKind: "unary"; + input: typeof ExampleRequestDesc; + output: typeof ExampleResponseDesc; }, /** * @generated from rpc spec.ExampleService.ServerStream */ serverStream: { - kind: "server_streaming"; - I: typeof ExampleRequestDesc; - O: typeof ExampleResponseDesc; + methodKind: "server_streaming"; + input: typeof ExampleRequestDesc; + output: typeof ExampleResponseDesc; }, /** * @generated from rpc spec.ExampleService.ClientStream */ clientStream: { - kind: "client_streaming"; - I: typeof ExampleRequestDesc; - O: typeof ExampleResponseDesc; + methodKind: "client_streaming"; + input: typeof ExampleRequestDesc; + output: typeof ExampleResponseDesc; }, /** * @generated from rpc spec.ExampleService.Bidi */ bidi: { - kind: "bidi_streaming"; - I: typeof ExampleRequestDesc; - O: typeof ExampleResponseDesc; + methodKind: "bidi_streaming"; + input: typeof ExampleRequestDesc; + output: typeof ExampleResponseDesc; }, } >; diff --git a/packages/protobuf-test/src/gen/js/google/protobuf/unittest_custom_options_pb.d.ts b/packages/protobuf-test/src/gen/js/google/protobuf/unittest_custom_options_pb.d.ts index 014546a69..0e7e21a64 100644 --- a/packages/protobuf-test/src/gen/js/google/protobuf/unittest_custom_options_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/google/protobuf/unittest_custom_options_pb.d.ts @@ -678,9 +678,9 @@ export declare const TestServiceWithCustomOptions: GenDescService<{ * @generated from rpc protobuf_unittest.TestServiceWithCustomOptions.Foo */ foo: { - kind: "unary"; - I: typeof CustomOptionFooRequestDesc; - O: typeof CustomOptionFooResponseDesc; + methodKind: "unary"; + input: typeof CustomOptionFooRequestDesc; + output: typeof CustomOptionFooResponseDesc; }, } >; @@ -693,9 +693,9 @@ export declare const AggregateService: GenDescService<{ * @generated from rpc protobuf_unittest.AggregateService.Method */ method: { - kind: "unary"; - I: typeof AggregateMessageDesc; - O: typeof AggregateMessageDesc; + methodKind: "unary"; + input: typeof AggregateMessageDesc; + output: typeof AggregateMessageDesc; }, } >; diff --git a/packages/protobuf-test/src/gen/js/google/protobuf/unittest_no_generic_services_pb.d.ts b/packages/protobuf-test/src/gen/js/google/protobuf/unittest_no_generic_services_pb.d.ts index 623e9ba0a..9e1e0246b 100644 --- a/packages/protobuf-test/src/gen/js/google/protobuf/unittest_no_generic_services_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/google/protobuf/unittest_no_generic_services_pb.d.ts @@ -65,9 +65,9 @@ export declare const TestService: GenDescService<{ * @generated from rpc protobuf_unittest.no_generic_services_test.TestService.Foo */ foo: { - kind: "unary"; - I: typeof TestMessageDesc; - O: typeof TestMessageDesc; + methodKind: "unary"; + input: typeof TestMessageDesc; + output: typeof TestMessageDesc; }, } >; diff --git a/packages/protobuf-test/src/gen/js/google/protobuf/unittest_pb.d.ts b/packages/protobuf-test/src/gen/js/google/protobuf/unittest_pb.d.ts index e571c1782..a3f050653 100644 --- a/packages/protobuf-test/src/gen/js/google/protobuf/unittest_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/google/protobuf/unittest_pb.d.ts @@ -6794,17 +6794,17 @@ export declare const TestService: GenDescService<{ * @generated from rpc protobuf_unittest.TestService.Foo */ foo: { - kind: "unary"; - I: typeof FooRequestDesc; - O: typeof FooResponseDesc; + methodKind: "unary"; + input: typeof FooRequestDesc; + output: typeof FooResponseDesc; }, /** * @generated from rpc protobuf_unittest.TestService.Bar */ bar: { - kind: "unary"; - I: typeof BarRequestDesc; - O: typeof BarResponseDesc; + methodKind: "unary"; + input: typeof BarRequestDesc; + output: typeof BarResponseDesc; }, } >; diff --git a/packages/protobuf-test/src/gen/js/google/protobuf/unittest_retention_pb.d.ts b/packages/protobuf-test/src/gen/js/google/protobuf/unittest_retention_pb.d.ts index f0d548dd0..177e091cb 100644 --- a/packages/protobuf-test/src/gen/js/google/protobuf/unittest_retention_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/google/protobuf/unittest_retention_pb.d.ts @@ -147,9 +147,9 @@ export declare const Service: GenDescService<{ * @generated from rpc protobuf_unittest.Service.DoStuff */ doStuff: { - kind: "unary"; - I: typeof TopLevelMessageDesc; - O: typeof TopLevelMessageDesc; + methodKind: "unary"; + input: typeof TopLevelMessageDesc; + output: typeof TopLevelMessageDesc; }, } >; diff --git a/packages/protobuf-test/src/gen/ts/extra/deprecation-explicit_pb.ts b/packages/protobuf-test/src/gen/ts/extra/deprecation-explicit_pb.ts index 7691663de..a6d3c3244 100644 --- a/packages/protobuf-test/src/gen/ts/extra/deprecation-explicit_pb.ts +++ b/packages/protobuf-test/src/gen/ts/extra/deprecation-explicit_pb.ts @@ -138,9 +138,9 @@ export const DeprecatedService: GenDescService<{ * @generated from rpc spec.DeprecatedService.Deprecated */ deprecated: { - kind: "unary"; - I: typeof EmptyDesc; - O: typeof EmptyDesc; + methodKind: "unary"; + input: typeof EmptyDesc; + output: typeof EmptyDesc; }, } > = /*@__PURE__*/ @@ -157,17 +157,17 @@ export const DeprecatedRpcService: GenDescService<{ * @deprecated */ deprecated: { - kind: "unary"; - I: typeof EmptyDesc; - O: typeof EmptyDesc; + methodKind: "unary"; + input: typeof EmptyDesc; + output: typeof EmptyDesc; }, /** * @generated from rpc spec.DeprecatedRpcService.NotDeprecated */ notDeprecated: { - kind: "unary"; - I: typeof EmptyDesc; - O: typeof EmptyDesc; + methodKind: "unary"; + input: typeof EmptyDesc; + output: typeof EmptyDesc; }, } > = /*@__PURE__*/ diff --git a/packages/protobuf-test/src/gen/ts/extra/deprecation-implicit_pb.ts b/packages/protobuf-test/src/gen/ts/extra/deprecation-implicit_pb.ts index cce253381..852d470d1 100644 --- a/packages/protobuf-test/src/gen/ts/extra/deprecation-implicit_pb.ts +++ b/packages/protobuf-test/src/gen/ts/extra/deprecation-implicit_pb.ts @@ -75,9 +75,9 @@ export const ImplicitlyDeprecatedService: GenDescService<{ * @generated from rpc spec.ImplicitlyDeprecatedService.ImplicitlyDeprecatedRpc */ implicitlyDeprecatedRpc: { - kind: "unary"; - I: typeof EmptyDesc; - O: typeof EmptyDesc; + methodKind: "unary"; + input: typeof EmptyDesc; + output: typeof EmptyDesc; }, } > = /*@__PURE__*/ diff --git a/packages/protobuf-test/src/gen/ts/extra/name-clash_pb.ts b/packages/protobuf-test/src/gen/ts/extra/name-clash_pb.ts index a6e0387f2..7278549b0 100644 --- a/packages/protobuf-test/src/gen/ts/extra/name-clash_pb.ts +++ b/packages/protobuf-test/src/gen/ts/extra/name-clash_pb.ts @@ -1023,33 +1023,33 @@ export const ReservedPropertyNamesService: GenDescService<{ * @generated from rpc spec.ReservedPropertyNamesService.constructor */ constructor$: { - kind: "unary"; - I: typeof ErrorDesc; - O: typeof ErrorDesc; + methodKind: "unary"; + input: typeof ErrorDesc; + output: typeof ErrorDesc; }, /** * @generated from rpc spec.ReservedPropertyNamesService.toString */ toString$: { - kind: "unary"; - I: typeof ErrorDesc; - O: typeof ErrorDesc; + methodKind: "unary"; + input: typeof ErrorDesc; + output: typeof ErrorDesc; }, /** * @generated from rpc spec.ReservedPropertyNamesService.to_JSON */ to_JSON: { - kind: "unary"; - I: typeof ErrorDesc; - O: typeof ErrorDesc; + methodKind: "unary"; + input: typeof ErrorDesc; + output: typeof ErrorDesc; }, /** * @generated from rpc spec.ReservedPropertyNamesService.value_of */ value_of: { - kind: "unary"; - I: typeof ErrorDesc; - O: typeof ErrorDesc; + methodKind: "unary"; + input: typeof ErrorDesc; + output: typeof ErrorDesc; }, } > = /*@__PURE__*/ diff --git a/packages/protobuf-test/src/gen/ts/extra/option-usage_pb.ts b/packages/protobuf-test/src/gen/ts/extra/option-usage_pb.ts index 4aa546093..c0fb60633 100644 --- a/packages/protobuf-test/src/gen/ts/extra/option-usage_pb.ts +++ b/packages/protobuf-test/src/gen/ts/extra/option-usage_pb.ts @@ -79,9 +79,9 @@ export const ServiceWithOptions: GenDescService<{ * @generated from rpc spec.ServiceWithOptions.Foo */ foo: { - kind: "unary"; - I: typeof MessageWithOptionsDesc; - O: typeof MessageWithOptionsDesc; + methodKind: "unary"; + input: typeof MessageWithOptionsDesc; + output: typeof MessageWithOptionsDesc; }, } > = /*@__PURE__*/ diff --git a/packages/protobuf-test/src/gen/ts/extra/service-all_pb.ts b/packages/protobuf-test/src/gen/ts/extra/service-all_pb.ts index adee82662..e654f3b10 100644 --- a/packages/protobuf-test/src/gen/ts/extra/service-all_pb.ts +++ b/packages/protobuf-test/src/gen/ts/extra/service-all_pb.ts @@ -35,34 +35,34 @@ export const ServiceAll: GenDescService<{ * @generated from rpc spec.ServiceAll.Unary */ unary: { - kind: "unary"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "unary"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }, /** * @generated from rpc spec.ServiceAll.ServerStream */ serverStream: { - kind: "server_streaming"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "server_streaming"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }, /** * @generated from rpc spec.ServiceAll.ClientStream */ clientStream: { - kind: "client_streaming"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "client_streaming"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }, /** * @generated from rpc spec.ServiceAll.Bidi * @deprecated */ bidi: { - kind: "bidi_streaming"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "bidi_streaming"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }, } > = /*@__PURE__*/ diff --git a/packages/protobuf-test/src/gen/ts/extra/service-example_pb.ts b/packages/protobuf-test/src/gen/ts/extra/service-example_pb.ts index 3a98d516b..00d47e57f 100644 --- a/packages/protobuf-test/src/gen/ts/extra/service-example_pb.ts +++ b/packages/protobuf-test/src/gen/ts/extra/service-example_pb.ts @@ -154,33 +154,33 @@ export const ExampleService: GenDescService<{ * @generated from rpc spec.ExampleService.Unary */ unary: { - kind: "unary"; - I: typeof ExampleRequestDesc; - O: typeof ExampleResponseDesc; + methodKind: "unary"; + input: typeof ExampleRequestDesc; + output: typeof ExampleResponseDesc; }, /** * @generated from rpc spec.ExampleService.ServerStream */ serverStream: { - kind: "server_streaming"; - I: typeof ExampleRequestDesc; - O: typeof ExampleResponseDesc; + methodKind: "server_streaming"; + input: typeof ExampleRequestDesc; + output: typeof ExampleResponseDesc; }, /** * @generated from rpc spec.ExampleService.ClientStream */ clientStream: { - kind: "client_streaming"; - I: typeof ExampleRequestDesc; - O: typeof ExampleResponseDesc; + methodKind: "client_streaming"; + input: typeof ExampleRequestDesc; + output: typeof ExampleResponseDesc; }, /** * @generated from rpc spec.ExampleService.Bidi */ bidi: { - kind: "bidi_streaming"; - I: typeof ExampleRequestDesc; - O: typeof ExampleResponseDesc; + methodKind: "bidi_streaming"; + input: typeof ExampleRequestDesc; + output: typeof ExampleResponseDesc; }, } > = /*@__PURE__*/ diff --git a/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_custom_options_pb.ts b/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_custom_options_pb.ts index ce07d459d..3f6d60800 100644 --- a/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_custom_options_pb.ts +++ b/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_custom_options_pb.ts @@ -720,9 +720,9 @@ export const TestServiceWithCustomOptions: GenDescService<{ * @generated from rpc protobuf_unittest.TestServiceWithCustomOptions.Foo */ foo: { - kind: "unary"; - I: typeof CustomOptionFooRequestDesc; - O: typeof CustomOptionFooResponseDesc; + methodKind: "unary"; + input: typeof CustomOptionFooRequestDesc; + output: typeof CustomOptionFooResponseDesc; }, } > = /*@__PURE__*/ @@ -736,9 +736,9 @@ export const AggregateService: GenDescService<{ * @generated from rpc protobuf_unittest.AggregateService.Method */ method: { - kind: "unary"; - I: typeof AggregateMessageDesc; - O: typeof AggregateMessageDesc; + methodKind: "unary"; + input: typeof AggregateMessageDesc; + output: typeof AggregateMessageDesc; }, } > = /*@__PURE__*/ diff --git a/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_no_generic_services_pb.ts b/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_no_generic_services_pb.ts index 565bf4895..16cc92cf0 100644 --- a/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_no_generic_services_pb.ts +++ b/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_no_generic_services_pb.ts @@ -69,9 +69,9 @@ export const TestService: GenDescService<{ * @generated from rpc protobuf_unittest.no_generic_services_test.TestService.Foo */ foo: { - kind: "unary"; - I: typeof TestMessageDesc; - O: typeof TestMessageDesc; + methodKind: "unary"; + input: typeof TestMessageDesc; + output: typeof TestMessageDesc; }, } > = /*@__PURE__*/ diff --git a/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_pb.ts b/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_pb.ts index f077f463e..2dca08ff9 100644 --- a/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_pb.ts +++ b/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_pb.ts @@ -6992,17 +6992,17 @@ export const TestService: GenDescService<{ * @generated from rpc protobuf_unittest.TestService.Foo */ foo: { - kind: "unary"; - I: typeof FooRequestDesc; - O: typeof FooResponseDesc; + methodKind: "unary"; + input: typeof FooRequestDesc; + output: typeof FooResponseDesc; }, /** * @generated from rpc protobuf_unittest.TestService.Bar */ bar: { - kind: "unary"; - I: typeof BarRequestDesc; - O: typeof BarResponseDesc; + methodKind: "unary"; + input: typeof BarRequestDesc; + output: typeof BarResponseDesc; }, } > = /*@__PURE__*/ diff --git a/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_retention_pb.ts b/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_retention_pb.ts index 71a36a4f8..abe1bb9ea 100644 --- a/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_retention_pb.ts +++ b/packages/protobuf-test/src/gen/ts/google/protobuf/unittest_retention_pb.ts @@ -157,9 +157,9 @@ export const Service: GenDescService<{ * @generated from rpc protobuf_unittest.Service.DoStuff */ doStuff: { - kind: "unary"; - I: typeof TopLevelMessageDesc; - O: typeof TopLevelMessageDesc; + methodKind: "unary"; + input: typeof TopLevelMessageDesc; + output: typeof TopLevelMessageDesc; }, } > = /*@__PURE__*/ diff --git a/packages/protobuf-test/src/generate-code.test.ts b/packages/protobuf-test/src/generate-code.test.ts index caae2ee1a..8d511744a 100644 --- a/packages/protobuf-test/src/generate-code.test.ts +++ b/packages/protobuf-test/src/generate-code.test.ts @@ -158,24 +158,24 @@ test("ts generated code is assignable to js", () => { test("service generates as expected", () => { type Expected = { unary: { - kind: "unary"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "unary"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }; serverStream: { - kind: "server_streaming"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "server_streaming"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }; clientStream: { - kind: "client_streaming"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "client_streaming"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }; bidi: { - kind: "bidi_streaming"; - I: typeof StringValueDesc; - O: typeof Int32ValueDesc; + methodKind: "bidi_streaming"; + input: typeof StringValueDesc; + output: typeof Int32ValueDesc; }; }; type Actual = T extends GenDescService ? Shape : never; diff --git a/packages/protobuf/src/codegenv1/service.ts b/packages/protobuf/src/codegenv1/service.ts index 4ee970433..a6cc621cd 100644 --- a/packages/protobuf/src/codegenv1/service.ts +++ b/packages/protobuf/src/codegenv1/service.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import type { GenDescService, GenDescServiceShape } from "./types.js"; +import type { GenDescService, GenDescServiceMethods } from "./types.js"; import type { DescFile } from "../descriptors.js"; /** @@ -20,7 +20,7 @@ import type { DescFile } from "../descriptors.js"; * * @private */ -export function serviceDesc( +export function serviceDesc( file: DescFile, path: number, ...paths: number[] diff --git a/packages/protobuf/src/codegenv1/types.ts b/packages/protobuf/src/codegenv1/types.ts index 7a2ab90a8..535830653 100644 --- a/packages/protobuf/src/codegenv1/types.ts +++ b/packages/protobuf/src/codegenv1/types.ts @@ -19,6 +19,7 @@ import type { DescField, DescFile, DescMessage, + DescMethod, DescService, } from "../descriptors.js"; @@ -74,19 +75,20 @@ export type GenDescExtension< * * @private */ -export type GenDescService = - DescService & brand; +export type GenDescService = Omit< + DescService, + "method" +> & { + method: { [K in keyof RuntimeShape]: RuntimeShape[K] & DescMethod }; +}; /** * @private */ -export type GenDescServiceShape = { - [localName: string]: { - kind: "unary" | "server_streaming" | "client_streaming" | "bidi_streaming"; - I: DescMessage; - O: DescMessage; - }; -}; +export type GenDescServiceMethods = Record< + string, + Pick +>; class brand { protected a: A | boolean = false; @@ -101,9 +103,9 @@ class brand { type MessageFieldNames = Message extends T ? string : Exclude ? K - : P + P extends ("$typeName" | "$unknown") ? never + : T[P] extends Oneof ? K + : P ]-?: true; }, number | symbol>; diff --git a/packages/protobuf/src/descriptors.ts b/packages/protobuf/src/descriptors.ts index cfb0eea62..1529dbf84 100644 --- a/packages/protobuf/src/descriptors.ts +++ b/packages/protobuf/src/descriptors.ts @@ -666,6 +666,10 @@ export interface DescService { * The RPCs this service declares. */ readonly methods: DescMethod[]; + /** + * All methods of this service by their "localName". + */ + readonly method: Record; /** * Marked as deprecated in the protobuf source. */ diff --git a/packages/protobuf/src/registry.ts b/packages/protobuf/src/registry.ts index a29ffd57d..d2f9dfc46 100644 --- a/packages/protobuf/src/registry.ts +++ b/packages/protobuf/src/registry.ts @@ -670,6 +670,7 @@ function addService( name: proto.name, typeName: makeTypeName(proto, undefined, file), methods: [], + method: {}, toString(): string { return `service ${this.typeName}`; }, @@ -677,7 +678,9 @@ function addService( file.services.push(desc); reg.add(desc); for (const methodProto of proto.method) { - desc.methods.push(newMethod(methodProto, desc, reg)); + const method = newMethod(methodProto, desc, reg); + desc.methods.push(method); + desc.method[method.localName] = method; } } diff --git a/packages/protobuf/src/types.ts b/packages/protobuf/src/types.ts index da81c8e0c..bb06386db 100644 --- a/packages/protobuf/src/types.ts +++ b/packages/protobuf/src/types.ts @@ -80,9 +80,6 @@ export type UnknownField = { readonly data: Uint8Array; }; -// TODO ServiceShape? -// TODO MethodShape? - /** * The init type for a message, which makes all fields optional. * The init type is accepted by the function create(). diff --git a/packages/protoc-gen-es/src/protoc-gen-es-plugin.ts b/packages/protoc-gen-es/src/protoc-gen-es-plugin.ts index 154dcaf3e..4fa12827c 100644 --- a/packages/protoc-gen-es/src/protoc-gen-es-plugin.ts +++ b/packages/protoc-gen-es/src/protoc-gen-es-plugin.ts @@ -299,9 +299,9 @@ function getServiceShapeExpr(f: GeneratedFile, service: DescService): Printable for (const method of service.methods) { print(f.jsDoc(method, " ")); print(" ", method.localName, ": {"); - print(" kind: ", f.string(method.methodKind), ";"); - print(" I: typeof ", f.importDesc(method.input, true), ";"); - print(" O: typeof ", f.importDesc(method.output, true), ";"); + print(" methodKind: ", f.string(method.methodKind), ";"); + print(" input: typeof ", f.importDesc(method.input, true), ";"); + print(" output: typeof ", f.importDesc(method.output, true), ";"); print(" },"); } print("}"); diff --git a/packages/protoplugin-example/src/gen/connectrpc/eliza_pb.ts b/packages/protoplugin-example/src/gen/connectrpc/eliza_pb.ts index f5def2d0f..8efb09a34 100644 --- a/packages/protoplugin-example/src/gen/connectrpc/eliza_pb.ts +++ b/packages/protoplugin-example/src/gen/connectrpc/eliza_pb.ts @@ -77,9 +77,9 @@ export const ElizaService: GenDescService<{ * @generated from rpc connectrpc.eliza.v1.ElizaService.Say */ say: { - kind: "unary"; - I: typeof SayRequestDesc; - O: typeof SayResponseDesc; + methodKind: "unary"; + input: typeof SayRequestDesc; + output: typeof SayResponseDesc; }, } > = /*@__PURE__*/