From 631a38710facf3159c3801b9f1abf73d32f175a5 Mon Sep 17 00:00:00 2001 From: Andres Correa Casablanca Date: Mon, 18 Oct 2021 11:17:51 +0200 Subject: [PATCH 1/6] feat: add version package --- version/version.go | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 version/version.go diff --git a/version/version.go b/version/version.go new file mode 100644 index 0000000..072f90d --- /dev/null +++ b/version/version.go @@ -0,0 +1,9 @@ +package version + +var ( + MajorVersion = "2" + MinorVersion = "1" + PatchVersion = "0" + BuildCommit = "" + BuildTime = "" +) From 464ba8ae7ba9b788e47d6c04dbf72768f41514b8 Mon Sep 17 00:00:00 2001 From: Andres Correa Casablanca Date: Mon, 18 Oct 2021 11:44:46 +0200 Subject: [PATCH 2/6] build: pass version info to build step --- build.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index e2eac25..9e65998 100755 --- a/build.sh +++ b/build.sh @@ -1,10 +1,19 @@ #!/bin/sh +# Flags +COMMIT_HASH="$(git rev-parse --short HEAD)" +BUILD_TIME="$(date +%s)" + +COMMIT_FLAG="-X 'github.com/join-com/protoc-gen-ts/version.BuildCommit=${COMMIT_HASH}'" +TIME_FLAG="-X 'github.com/join-com/protoc-gen-ts/version.BuildTime=${BUILD_TIME}'" + +GO_LD_FLAGS="${COMMIT_FLAG} ${TIME_FLAG}" + # Building binary -env GOOS=darwin GOARCH=amd64 go build -o ./dist/protoc-gen-tsx.darwin.amd64 -env GOOS=darwin GOARCH=arm64 go build -o ./dist/protoc-gen-tsx.darwin.arm64 -env GOOS=linux GOARCH=amd64 go build -o ./dist/protoc-gen-tsx.linux.amd64 -env GOOS=linux GOARCH=arm64 go build -o ./dist/protoc-gen-tsx.linux.arm64 +env GOOS=darwin GOARCH=amd64 go build -ldflags="${GO_LD_FLAGS}" -o ./dist/protoc-gen-tsx.darwin.amd64 +env GOOS=darwin GOARCH=arm64 go build -ldflags="${GO_LD_FLAGS}" -o ./dist/protoc-gen-tsx.darwin.arm64 +env GOOS=linux GOARCH=amd64 go build -ldflags="${GO_LD_FLAGS}" -o ./dist/protoc-gen-tsx.linux.amd64 +env GOOS=linux GOARCH=arm64 go build -ldflags="${GO_LD_FLAGS}" -o ./dist/protoc-gen-tsx.linux.arm64 rm -f ./dist/protoc-gen-tsx; From 4201f9ae382428469ec9436367ff072080942e75 Mon Sep 17 00:00:00 2001 From: Andres Correa Casablanca Date: Mon, 18 Oct 2021 11:45:34 +0200 Subject: [PATCH 3/6] feat: add version info to generated files --- internal/generator/runner_generate.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/generator/runner_generate.go b/internal/generator/runner_generate.go index c95c165..dbbbb03 100644 --- a/internal/generator/runner_generate.go +++ b/internal/generator/runner_generate.go @@ -12,6 +12,7 @@ import ( "github.com/iancoleman/strcase" "github.com/join-com/protoc-gen-ts/internal/join_proto" "github.com/join-com/protoc-gen-ts/internal/utils" + "github.com/join-com/protoc-gen-ts/version" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/types/descriptorpb" ) @@ -20,6 +21,7 @@ func (r *Runner) generateTypescriptFile(protoFile *protogen.File, generatedFileS // TODO: Generate comment with version, in order to improve traceability & debugging experience generatedFileStream.P( "// GENERATED CODE -- DO NOT EDIT!\n", + "// GENERATOR VERSION: "+version.MajorVersion+"."+version.MinorVersion+"."+version.PatchVersion+"."+version.BuildCommit+"."+version.BuildTime+"\n", "/* eslint-disable @typescript-eslint/no-non-null-assertion */\n", ) From dc3bd08ec6cf8d1301d7c82adcbe0c25944baf30 Mon Sep 17 00:00:00 2001 From: Andres Correa Casablanca Date: Mon, 18 Oct 2021 11:46:22 +0200 Subject: [PATCH 4/6] chore: regenerate 'generated' files --- tests/.eslintignore | 1 + tests/__tests__/generated/Flavors.ts | 1 + tests/__tests__/generated/Regressions.ts | 1 + tests/__tests__/generated/Test.ts | 1 + tests/__tests__/generated/common/Common.ts | 1 + tests/__tests__/generated/common/Extra.ts | 1 + .../generated/google/protobuf/Empty.ts | 1 + .../generated/google/protobuf/Timestamp.ts | 1 + tests/__tests__/generatedRedundant/Flavors.ts | 221 +++++ tests/__tests__/generatedRedundant/README | 1 + .../generatedRedundant/Regressions.ts | 234 +++++ tests/__tests__/generatedRedundant/Test.ts | 893 ++++++++++++++++++ .../generatedRedundant/common/Common.ts | 70 ++ .../generatedRedundant/common/Extra.ts | 95 ++ .../google/protobuf/Empty.ts | 52 + .../google/protobuf/Timestamp.ts | 61 ++ tests/package.json | 5 +- 17 files changed, 1638 insertions(+), 2 deletions(-) create mode 100644 tests/__tests__/generatedRedundant/Flavors.ts create mode 100644 tests/__tests__/generatedRedundant/README create mode 100644 tests/__tests__/generatedRedundant/Regressions.ts create mode 100644 tests/__tests__/generatedRedundant/Test.ts create mode 100644 tests/__tests__/generatedRedundant/common/Common.ts create mode 100644 tests/__tests__/generatedRedundant/common/Extra.ts create mode 100644 tests/__tests__/generatedRedundant/google/protobuf/Empty.ts create mode 100644 tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts diff --git a/tests/.eslintignore b/tests/.eslintignore index 7f9d5fe..3d86403 100644 --- a/tests/.eslintignore +++ b/tests/.eslintignore @@ -1,3 +1,4 @@ generated/ generatedLegacy/ +generatedRedundant/ node_modules/ diff --git a/tests/__tests__/generated/Flavors.ts b/tests/__tests__/generated/Flavors.ts index b85b862..396b156 100644 --- a/tests/__tests__/generated/Flavors.ts +++ b/tests/__tests__/generated/Flavors.ts @@ -1,4 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as joinGRPC from '@join-com/grpc' diff --git a/tests/__tests__/generated/Regressions.ts b/tests/__tests__/generated/Regressions.ts index 679bf57..94eabf4 100644 --- a/tests/__tests__/generated/Regressions.ts +++ b/tests/__tests__/generated/Regressions.ts @@ -1,4 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generated/Test.ts b/tests/__tests__/generated/Test.ts index ab850dc..731fe10 100644 --- a/tests/__tests__/generated/Test.ts +++ b/tests/__tests__/generated/Test.ts @@ -1,4 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as joinGRPC from '@join-com/grpc' diff --git a/tests/__tests__/generated/common/Common.ts b/tests/__tests__/generated/common/Common.ts index edf5aa0..315773d 100644 --- a/tests/__tests__/generated/common/Common.ts +++ b/tests/__tests__/generated/common/Common.ts @@ -1,4 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generated/common/Extra.ts b/tests/__tests__/generated/common/Extra.ts index 7b9155f..ee786c3 100644 --- a/tests/__tests__/generated/common/Extra.ts +++ b/tests/__tests__/generated/common/Extra.ts @@ -1,4 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generated/google/protobuf/Empty.ts b/tests/__tests__/generated/google/protobuf/Empty.ts index 31c9b7f..789321f 100644 --- a/tests/__tests__/generated/google/protobuf/Empty.ts +++ b/tests/__tests__/generated/google/protobuf/Empty.ts @@ -1,4 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generated/google/protobuf/Timestamp.ts b/tests/__tests__/generated/google/protobuf/Timestamp.ts index 49fff51..f38d0a4 100644 --- a/tests/__tests__/generated/google/protobuf/Timestamp.ts +++ b/tests/__tests__/generated/google/protobuf/Timestamp.ts @@ -1,4 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generatedRedundant/Flavors.ts b/tests/__tests__/generatedRedundant/Flavors.ts new file mode 100644 index 0000000..396b156 --- /dev/null +++ b/tests/__tests__/generatedRedundant/Flavors.ts @@ -0,0 +1,221 @@ +// GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + +import * as joinGRPC from '@join-com/grpc' +import * as protobufjs from 'protobufjs/light' + +import { WithFlavor } from '@coderspirit/nominal' + +import { grpc } from '@join-com/grpc' + +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace Flavors { + interface ConvertibleTo { + asInterface(): T + } + + export type Email = WithFlavor + export type UserId = WithFlavor + + export interface IUserRequest { + userId?: UserId + } + + export interface IUserProfile { + id: UserId + username: string + emails: Email[] + } + + @protobufjs.Type.d('flavors_UserProfile') + export class UserProfile + extends protobufjs.Message + implements ConvertibleTo, IUserProfile + { + @protobufjs.Field.d(1, 'int32') + public id!: UserId + + @protobufjs.Field.d(2, 'string') + public username!: string + + @protobufjs.Field.d(3, 'string', 'repeated') + public emails!: Email[] + + public asInterface(): IUserProfile { + const message = { + ...this, + } + for (const fieldName of Object.keys(message)) { + const field = message[fieldName as keyof IUserProfile] + if (field == null || (Array.isArray(field) && field.length === 0)) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof IUserProfile] + } + } + return message + } + + public static fromInterface(this: void, value: IUserProfile): UserProfile { + return UserProfile.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IUserProfile { + const message = UserProfile.decode(reader).asInterface() + for (const fieldName of [ + 'id', + 'username', + 'emails', + ] as (keyof IUserProfile)[]) { + const field = message[fieldName] + if (field == null || (Array.isArray(field) && field.length === 0)) { + throw new Error( + `Required field ${fieldName} in UserProfile is null or undefined` + ) + } + } + return message + } + + public static encodePatched( + this: void, + message: IUserProfile, + writer?: protobufjs.Writer + ): protobufjs.Writer { + for (const fieldName of [ + 'id', + 'username', + 'emails', + ] as (keyof IUserProfile)[]) { + const field = message[fieldName] + if (field == null || (Array.isArray(field) && field.length === 0)) { + throw new Error( + `Required field ${fieldName} in UserProfile is null or undefined` + ) + } + } + return UserProfile.encode(message, writer) + } + } + + @protobufjs.Type.d('flavors_UserRequest') + export class UserRequest + extends protobufjs.Message + implements ConvertibleTo, IUserRequest + { + @protobufjs.Field.d(1, 'int32', 'optional') + public userId?: UserId + + public asInterface(): IUserRequest { + const message = { + ...this, + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof IUserRequest] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof IUserRequest] + } + } + return message + } + + public static fromInterface(this: void, value: IUserRequest): UserRequest { + return UserRequest.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IUserRequest { + return UserRequest.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: IUserRequest, + writer?: protobufjs.Writer + ): protobufjs.Writer { + return UserRequest.encode(message, writer) + } + } + + export interface IUsersServiceImplementation { + Find: grpc.handleUnaryCall + } + + export const usersServiceDefinition: grpc.ServiceDefinition = + { + Find: { + path: '/flavors.Users/Find', + requestStream: false, + responseStream: false, + requestSerialize: (request: IUserRequest) => + UserRequest.encodePatched(request).finish() as Buffer, + requestDeserialize: UserRequest.decodePatched, + responseSerialize: (response: IUserProfile) => + UserProfile.encodePatched(response).finish() as Buffer, + responseDeserialize: UserProfile.decodePatched, + }, + } + + export abstract class AbstractUsersService extends joinGRPC.Service { + constructor( + protected readonly logger?: joinGRPC.INoDebugLogger, + trace?: joinGRPC.IServiceTrace + ) { + super( + usersServiceDefinition, + { + find: (call) => this.Find(call), + }, + logger, + trace + ) + } + + public abstract Find( + call: grpc.ServerUnaryCall + ): Promise + } + + export interface IUsersClient + extends joinGRPC.IExtendedClient< + IUsersServiceImplementation, + 'flavors.Users' + > { + find( + request: IUserRequest, + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IUnaryRequest + } + + export class UsersClient + extends joinGRPC.Client + implements IUsersClient + { + constructor( + config: joinGRPC.ISimplifiedClientConfig + ) { + super( + { + ...config, + serviceDefinition: usersServiceDefinition, + credentials: config?.credentials ?? grpc.credentials.createInsecure(), + }, + 'flavors.Users' + ) + } + + public find( + request: IUserRequest, + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IUnaryRequest { + return this.makeUnaryRequest('Find', request, metadata, options) + } + } +} diff --git a/tests/__tests__/generatedRedundant/README b/tests/__tests__/generatedRedundant/README new file mode 100644 index 0000000..b73bdbe --- /dev/null +++ b/tests/__tests__/generatedRedundant/README @@ -0,0 +1 @@ +For regression tests diff --git a/tests/__tests__/generatedRedundant/Regressions.ts b/tests/__tests__/generatedRedundant/Regressions.ts new file mode 100644 index 0000000..94eabf4 --- /dev/null +++ b/tests/__tests__/generatedRedundant/Regressions.ts @@ -0,0 +1,234 @@ +// GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + +import * as protobufjs from 'protobufjs/light' + +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace Regressions { + interface ConvertibleTo { + asInterface(): T + } + + export interface IReg01Inner { + value?: string + } + + export interface IReg01Outer { + inner?: IReg01Inner + } + + export interface IMessageWithDeprecatedField { + notDeprecated?: string + /** + * @deprecated + */ + deprecated?: string + } + + /** + * @deprecated + */ + export interface IDeprecatedMessageWithDeprecatedField { + notDeprecated?: string + /** + * @deprecated + */ + deprecated?: string + } + + /** + * @deprecated + */ + @protobufjs.Type.d('regressions_DeprecatedMessageWithDeprecatedField') + export class DeprecatedMessageWithDeprecatedField + extends protobufjs.Message + implements + ConvertibleTo, + IDeprecatedMessageWithDeprecatedField + { + @protobufjs.Field.d(1, 'string', 'optional') + public notDeprecated?: string + + /** + * @deprecated + */ + @protobufjs.Field.d(2, 'string', 'optional') + public deprecated?: string + + public asInterface(): IDeprecatedMessageWithDeprecatedField { + const message = { + ...this, + } + for (const fieldName of Object.keys(message)) { + if ( + message[fieldName as keyof IDeprecatedMessageWithDeprecatedField] == + null + ) { + // We remove the key to avoid problems with code making too many assumptions + delete message[ + fieldName as keyof IDeprecatedMessageWithDeprecatedField + ] + } + } + return message + } + + public static fromInterface( + this: void, + value: IDeprecatedMessageWithDeprecatedField + ): DeprecatedMessageWithDeprecatedField { + return DeprecatedMessageWithDeprecatedField.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IDeprecatedMessageWithDeprecatedField { + return DeprecatedMessageWithDeprecatedField.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: IDeprecatedMessageWithDeprecatedField, + writer?: protobufjs.Writer + ): protobufjs.Writer { + return DeprecatedMessageWithDeprecatedField.encode(message, writer) + } + } + + @protobufjs.Type.d('regressions_MessageWithDeprecatedField') + export class MessageWithDeprecatedField + extends protobufjs.Message + implements + ConvertibleTo, + IMessageWithDeprecatedField + { + @protobufjs.Field.d(1, 'string', 'optional') + public notDeprecated?: string + + /** + * @deprecated + */ + @protobufjs.Field.d(2, 'string', 'optional') + public deprecated?: string + + public asInterface(): IMessageWithDeprecatedField { + const message = { + ...this, + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof IMessageWithDeprecatedField] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof IMessageWithDeprecatedField] + } + } + return message + } + + public static fromInterface( + this: void, + value: IMessageWithDeprecatedField + ): MessageWithDeprecatedField { + return MessageWithDeprecatedField.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IMessageWithDeprecatedField { + return MessageWithDeprecatedField.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: IMessageWithDeprecatedField, + writer?: protobufjs.Writer + ): protobufjs.Writer { + return MessageWithDeprecatedField.encode(message, writer) + } + } + + @protobufjs.Type.d('regressions_Reg01Inner') + export class Reg01Inner + extends protobufjs.Message + implements ConvertibleTo, IReg01Inner + { + @protobufjs.Field.d(1, 'string', 'optional') + public value?: string + + public asInterface(): IReg01Inner { + const message = { + ...this, + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof IReg01Inner] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof IReg01Inner] + } + } + return message + } + + public static fromInterface(this: void, value: IReg01Inner): Reg01Inner { + return Reg01Inner.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IReg01Inner { + return Reg01Inner.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: IReg01Inner, + writer?: protobufjs.Writer + ): protobufjs.Writer { + return Reg01Inner.encode(message, writer) + } + } + + @protobufjs.Type.d('regressions_Reg01Outer') + export class Reg01Outer + extends protobufjs.Message + implements ConvertibleTo, IReg01Outer + { + @protobufjs.Field.d(1, Reg01Inner, 'optional') + public inner?: Reg01Inner + + public asInterface(): IReg01Outer { + const message = { + ...this, + inner: this.inner?.asInterface(), + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof IReg01Outer] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof IReg01Outer] + } + } + return message + } + + public static fromInterface(this: void, value: IReg01Outer): Reg01Outer { + return Reg01Outer.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IReg01Outer { + return Reg01Outer.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: IReg01Outer, + writer?: protobufjs.Writer + ): protobufjs.Writer { + return Reg01Outer.encode(message, writer) + } + } +} diff --git a/tests/__tests__/generatedRedundant/Test.ts b/tests/__tests__/generatedRedundant/Test.ts new file mode 100644 index 0000000..731fe10 --- /dev/null +++ b/tests/__tests__/generatedRedundant/Test.ts @@ -0,0 +1,893 @@ +// GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + +import * as joinGRPC from '@join-com/grpc' +import * as protobufjs from 'protobufjs/light' + +import { Common as Common_Common } from './common/Common' +import { Common as Common_Extra } from './common/Extra' +import { GoogleProtobuf as GoogleProtobuf_Empty } from './google/protobuf/Empty' +import { GoogleProtobuf as GoogleProtobuf_Timestamp } from './google/protobuf/Timestamp' + +import { grpc } from '@join-com/grpc' + +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace Foo { + interface ConvertibleTo { + asInterface(): T + } + + export enum EnumType_Enum { + UNKNOWN = 0, + ADMIN = 1, + USER = 2, + } + export type EnumType = keyof typeof EnumType_Enum + + export enum Role_Enum { + VIEW = 0, + EDIT = 1, + } + export type Role = keyof typeof Role_Enum + + export interface IRequest { + id?: number + } + + /** + * @deprecated + */ + export interface INested { + title?: string + } + + export interface ITest { + fieldInt32?: number + fieldInt32Repeated?: number[] + fieldDouble?: number + fieldDoubleRepeated?: number[] + fieldFloat?: number + fieldFloatRepeated?: number[] + fieldUint32?: number + fieldUint32Repeated?: number[] + fieldUint64?: number + fieldUint64Repeated?: number[] + fieldSint32?: number + fieldSint32Repeated?: number[] + /** + * @deprecated + */ + fieldSint64?: number + fieldSint64Repeated?: number[] + fieldFixed32?: number + fieldFixed32Repeated?: number[] + fieldFixed64?: number + fieldFixed64Repeated?: number[] + fieldSfixed32?: number + fieldSfixed32Repeated?: number[] + fieldSfixed64?: number + fieldSfixed64Repeated?: number[] + fieldBool?: boolean + fieldBoolRepeated?: boolean[] + fieldString?: string + fieldStringRepeated?: string[] + fieldBytes?: Uint8Array + fieldBytesRepeated?: Uint8Array[] + fieldEnum?: EnumType + fieldEnumRepeated?: Role[] + message?: INested + messageRepeated?: INested[] + timestamp?: Date + timestampRepeated?: Date[] + otherPkgMessage?: Common_Common.IOtherPkgMessage + otherPkgMessageRepeated?: Common_Common.IOtherPkgMessage[] + fieldInt64?: number + fieldInt64Repeated?: number[] + } + + export interface IBigWrapper { + nestedTest?: ITest + } + + export interface ICustomOptionsTest { + requiredField: Common_Extra.IExtraPkgMessage + typicalOptionalField?: number + customOptionalField?: number + } + + export interface IRequiredPropertiesTest { + requiredField: number + customRequiredField: number + optionalField?: number + } + + @protobufjs.Type.d('foo_CustomOptionsTest') + export class CustomOptionsTest + extends protobufjs.Message + implements ConvertibleTo + { + @protobufjs.Field.d(1, Common_Extra.ExtraPkgMessage) + public requiredField!: Common_Extra.ExtraPkgMessage + + @protobufjs.Field.d(2, 'int32', 'optional') + public typicalOptionalField?: number + + @protobufjs.Field.d(3, 'int32', 'optional') + public customOptionalField?: number + + public asInterface(): ICustomOptionsTest { + const message = { + ...this, + requiredField: this.requiredField.asInterface(), + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof ICustomOptionsTest] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof ICustomOptionsTest] + } + } + return message + } + + public static fromInterface( + this: void, + value: ICustomOptionsTest + ): CustomOptionsTest { + const patchedValue = { + ...value, + requiredField: Common_Extra.ExtraPkgMessage.fromInterface( + value.requiredField + ), + } + + return CustomOptionsTest.fromObject(patchedValue) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): ICustomOptionsTest { + const message = CustomOptionsTest.decode(reader).asInterface() + for (const fieldName of [ + 'requiredField', + ] as (keyof ICustomOptionsTest)[]) { + if (message[fieldName] == null) { + throw new Error( + `Required field ${fieldName} in CustomOptionsTest is null or undefined` + ) + } + } + return message + } + + public static encodePatched( + this: void, + message: ICustomOptionsTest, + writer?: protobufjs.Writer + ): protobufjs.Writer { + for (const fieldName of [ + 'requiredField', + ] as (keyof ICustomOptionsTest)[]) { + if (message[fieldName] == null) { + throw new Error( + `Required field ${fieldName} in CustomOptionsTest is null or undefined` + ) + } + } + const transformedMessage = CustomOptionsTest.fromInterface(message) + return CustomOptionsTest.encode(transformedMessage, writer) + } + } + + /** + * @deprecated + */ + @protobufjs.Type.d('foo_Nested') + export class Nested + extends protobufjs.Message + implements ConvertibleTo, INested + { + @protobufjs.Field.d(1, 'string', 'optional') + public title?: string + + public asInterface(): INested { + const message = { + ...this, + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof INested] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof INested] + } + } + return message + } + + public static fromInterface(this: void, value: INested): Nested { + return Nested.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): INested { + return Nested.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: INested, + writer?: protobufjs.Writer + ): protobufjs.Writer { + return Nested.encode(message, writer) + } + } + + @protobufjs.Type.d('foo_Request') + export class Request + extends protobufjs.Message + implements ConvertibleTo, IRequest + { + @protobufjs.Field.d(1, 'int32', 'optional') + public id?: number + + public asInterface(): IRequest { + const message = { + ...this, + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof IRequest] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof IRequest] + } + } + return message + } + + public static fromInterface(this: void, value: IRequest): Request { + return Request.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IRequest { + return Request.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: IRequest, + writer?: protobufjs.Writer + ): protobufjs.Writer { + return Request.encode(message, writer) + } + } + + @protobufjs.Type.d('foo_RequiredPropertiesTest') + export class RequiredPropertiesTest + extends protobufjs.Message + implements ConvertibleTo, IRequiredPropertiesTest + { + @protobufjs.Field.d(1, 'int32') + public requiredField!: number + + @protobufjs.Field.d(2, 'int32') + public customRequiredField!: number + + @protobufjs.Field.d(3, 'int32', 'optional') + public optionalField?: number + + public asInterface(): IRequiredPropertiesTest { + const message = { + ...this, + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof IRequiredPropertiesTest] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof IRequiredPropertiesTest] + } + } + return message + } + + public static fromInterface( + this: void, + value: IRequiredPropertiesTest + ): RequiredPropertiesTest { + return RequiredPropertiesTest.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IRequiredPropertiesTest { + const message = RequiredPropertiesTest.decode(reader).asInterface() + for (const fieldName of [ + 'requiredField', + 'customRequiredField', + ] as (keyof IRequiredPropertiesTest)[]) { + if (message[fieldName] == null) { + throw new Error( + `Required field ${fieldName} in RequiredPropertiesTest is null or undefined` + ) + } + } + return message + } + + public static encodePatched( + this: void, + message: IRequiredPropertiesTest, + writer?: protobufjs.Writer + ): protobufjs.Writer { + for (const fieldName of [ + 'requiredField', + 'customRequiredField', + ] as (keyof IRequiredPropertiesTest)[]) { + if (message[fieldName] == null) { + throw new Error( + `Required field ${fieldName} in RequiredPropertiesTest is null or undefined` + ) + } + } + return RequiredPropertiesTest.encode(message, writer) + } + } + + @protobufjs.Type.d('foo_Test') + export class Test + extends protobufjs.Message + implements ConvertibleTo + { + @protobufjs.Field.d(1, 'int32', 'optional') + public fieldInt32?: number + + @protobufjs.Field.d(2, 'int32', 'repeated') + public fieldInt32Repeated?: number[] + + @protobufjs.Field.d(3, 'double', 'optional') + public fieldDouble?: number + + @protobufjs.Field.d(4, 'double', 'repeated') + public fieldDoubleRepeated?: number[] + + @protobufjs.Field.d(5, 'float', 'optional') + public fieldFloat?: number + + @protobufjs.Field.d(6, 'float', 'repeated') + public fieldFloatRepeated?: number[] + + @protobufjs.Field.d(7, 'uint32', 'optional') + public fieldUint32?: number + + @protobufjs.Field.d(8, 'uint32', 'repeated') + public fieldUint32Repeated?: number[] + + @protobufjs.Field.d(9, 'uint64', 'optional') + public fieldUint64?: number + + @protobufjs.Field.d(10, 'uint64', 'repeated') + public fieldUint64Repeated?: number[] + + @protobufjs.Field.d(11, 'sint32', 'optional') + public fieldSint32?: number + + @protobufjs.Field.d(12, 'sint32', 'repeated') + public fieldSint32Repeated?: number[] + + /** + * @deprecated + */ + @protobufjs.Field.d(13, 'sint64', 'optional') + public fieldSint64?: number + + @protobufjs.Field.d(14, 'sint64', 'repeated') + public fieldSint64Repeated?: number[] + + @protobufjs.Field.d(15, 'fixed32', 'optional') + public fieldFixed32?: number + + @protobufjs.Field.d(16, 'fixed32', 'repeated') + public fieldFixed32Repeated?: number[] + + @protobufjs.Field.d(17, 'fixed64', 'optional') + public fieldFixed64?: number + + @protobufjs.Field.d(18, 'fixed64', 'repeated') + public fieldFixed64Repeated?: number[] + + @protobufjs.Field.d(19, 'sfixed32', 'optional') + public fieldSfixed32?: number + + @protobufjs.Field.d(20, 'sfixed32', 'repeated') + public fieldSfixed32Repeated?: number[] + + @protobufjs.Field.d(21, 'sfixed64', 'optional') + public fieldSfixed64?: number + + @protobufjs.Field.d(22, 'sfixed64', 'repeated') + public fieldSfixed64Repeated?: number[] + + @protobufjs.Field.d(23, 'bool', 'optional') + public fieldBool?: boolean + + @protobufjs.Field.d(24, 'bool', 'repeated') + public fieldBoolRepeated?: boolean[] + + @protobufjs.Field.d(25, 'string', 'optional') + public fieldString?: string + + @protobufjs.Field.d(26, 'string', 'repeated') + public fieldStringRepeated?: string[] + + @protobufjs.Field.d(27, 'bytes', 'optional') + public fieldBytes?: Uint8Array + + @protobufjs.Field.d(28, 'bytes', 'repeated') + public fieldBytesRepeated?: Uint8Array[] + + @protobufjs.Field.d(29, EnumType_Enum, 'optional', '__JoinGrpcUndefined__') + public fieldEnum?: EnumType_Enum + + @protobufjs.Field.d(30, Role_Enum, 'repeated') + public fieldEnumRepeated?: Role_Enum[] + + @protobufjs.Field.d(33, Nested, 'optional') + public message?: Nested + + @protobufjs.Field.d(34, Nested, 'repeated') + public messageRepeated?: Nested[] + + @protobufjs.Field.d(35, GoogleProtobuf_Timestamp.Timestamp, 'optional') + public timestamp?: GoogleProtobuf_Timestamp.Timestamp + + @protobufjs.Field.d(36, GoogleProtobuf_Timestamp.Timestamp, 'repeated') + public timestampRepeated?: GoogleProtobuf_Timestamp.Timestamp[] + + @protobufjs.Field.d(37, Common_Common.OtherPkgMessage, 'optional') + public otherPkgMessage?: Common_Common.OtherPkgMessage + + @protobufjs.Field.d(38, Common_Common.OtherPkgMessage, 'repeated') + public otherPkgMessageRepeated?: Common_Common.OtherPkgMessage[] + + @protobufjs.Field.d(39, 'int64', 'optional') + public fieldInt64?: number + + @protobufjs.Field.d(40, 'int64', 'repeated') + public fieldInt64Repeated?: number[] + + public asInterface(): ITest { + const message = { + ...this, + fieldEnum: (this.fieldEnum != null + ? EnumType_Enum[this.fieldEnum]! + : undefined) as EnumType | undefined, + fieldEnumRepeated: this.fieldEnumRepeated?.map( + (e) => Role_Enum[e]! as Role + ), + message: this.message?.asInterface(), + messageRepeated: this.messageRepeated?.map((o) => o.asInterface()), + timestamp: + this.timestamp != null + ? new Date( + (this.timestamp.seconds ?? 0) * 1000 + + (this.timestamp.nanos ?? 0) / 1000000 + ) + : undefined, + timestampRepeated: this.timestampRepeated?.map( + (ts) => new Date((ts.seconds ?? 0) * 1000 + (ts.nanos ?? 0) / 1000000) + ), + otherPkgMessage: this.otherPkgMessage?.asInterface(), + otherPkgMessageRepeated: this.otherPkgMessageRepeated?.map((o) => + o.asInterface() + ), + } + for (const fieldName of Object.keys(message)) { + const field = message[fieldName as keyof ITest] + if (field == null || (Array.isArray(field) && field.length === 0)) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof ITest] + } + } + return message + } + + public static fromInterface(this: void, value: ITest): Test { + const patchedValue = { + ...value, + fieldEnum: (value.fieldEnum != null + ? EnumType_Enum[value.fieldEnum]! + : undefined) as EnumType_Enum | undefined, + fieldEnumRepeated: value.fieldEnumRepeated?.map((e) => Role_Enum[e]!), + timestamp: + value.timestamp != null + ? GoogleProtobuf_Timestamp.Timestamp.fromInterface({ + seconds: Math.floor(value.timestamp.getTime() / 1000), + nanos: value.timestamp.getMilliseconds() * 1000000, + }) + : undefined, + timestampRepeated: value.timestampRepeated?.map((d) => + GoogleProtobuf_Timestamp.Timestamp.fromInterface({ + seconds: Math.floor(d.getTime() / 1000), + nanos: d.getMilliseconds() * 1000000, + }) + ), + } + + return Test.fromObject(patchedValue) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): ITest { + return Test.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: ITest, + writer?: protobufjs.Writer + ): protobufjs.Writer { + const transformedMessage = Test.fromInterface(message) + return Test.encode(transformedMessage, writer) + } + } + + @protobufjs.Type.d('foo_BigWrapper') + export class BigWrapper + extends protobufjs.Message + implements ConvertibleTo + { + @protobufjs.Field.d(1, Test, 'optional') + public nestedTest?: Test + + public asInterface(): IBigWrapper { + const message = { + ...this, + nestedTest: this.nestedTest?.asInterface(), + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof IBigWrapper] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof IBigWrapper] + } + } + return message + } + + public static fromInterface(this: void, value: IBigWrapper): BigWrapper { + const patchedValue = { + ...value, + nestedTest: + value.nestedTest != null + ? Test.fromInterface(value.nestedTest) + : undefined, + } + + return BigWrapper.fromObject(patchedValue) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IBigWrapper { + return BigWrapper.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: IBigWrapper, + writer?: protobufjs.Writer + ): protobufjs.Writer { + const transformedMessage = BigWrapper.fromInterface(message) + return BigWrapper.encode(transformedMessage, writer) + } + } + + export interface IUsersServiceImplementation { + Find: grpc.handleUnaryCall + FindBidiStream: grpc.handleBidiStreamingCall< + IRequest, + Common_Common.IOtherPkgMessage + > + FindClientStream: grpc.handleClientStreamingCall< + IRequest, + Common_Common.IOtherPkgMessage + > + FindServerStream: grpc.handleServerStreamingCall< + IRequest, + Common_Common.IOtherPkgMessage + > + } + + export const usersServiceDefinition: grpc.ServiceDefinition = + { + Find: { + path: '/foo.Users/Find', + requestStream: false, + responseStream: false, + requestSerialize: (request: IRequest) => + Request.encodePatched(request).finish() as Buffer, + requestDeserialize: Request.decodePatched, + responseSerialize: (response: Common_Common.IOtherPkgMessage) => + Common_Common.OtherPkgMessage.encodePatched( + response + ).finish() as Buffer, + responseDeserialize: Common_Common.OtherPkgMessage.decodePatched, + }, + FindBidiStream: { + path: '/foo.Users/FindBidiStream', + requestStream: true, + responseStream: true, + requestSerialize: (request: IRequest) => + Request.encodePatched(request).finish() as Buffer, + requestDeserialize: Request.decodePatched, + responseSerialize: (response: Common_Common.IOtherPkgMessage) => + Common_Common.OtherPkgMessage.encodePatched( + response + ).finish() as Buffer, + responseDeserialize: Common_Common.OtherPkgMessage.decodePatched, + }, + FindClientStream: { + path: '/foo.Users/FindClientStream', + requestStream: true, + responseStream: false, + requestSerialize: (request: IRequest) => + Request.encodePatched(request).finish() as Buffer, + requestDeserialize: Request.decodePatched, + responseSerialize: (response: Common_Common.IOtherPkgMessage) => + Common_Common.OtherPkgMessage.encodePatched( + response + ).finish() as Buffer, + responseDeserialize: Common_Common.OtherPkgMessage.decodePatched, + }, + FindServerStream: { + path: '/foo.Users/FindServerStream', + requestStream: false, + responseStream: true, + requestSerialize: (request: IRequest) => + Request.encodePatched(request).finish() as Buffer, + requestDeserialize: Request.decodePatched, + responseSerialize: (response: Common_Common.IOtherPkgMessage) => + Common_Common.OtherPkgMessage.encodePatched( + response + ).finish() as Buffer, + responseDeserialize: Common_Common.OtherPkgMessage.decodePatched, + }, + } + + export abstract class AbstractUsersService extends joinGRPC.Service { + constructor( + protected readonly logger?: joinGRPC.INoDebugLogger, + trace?: joinGRPC.IServiceTrace + ) { + super( + usersServiceDefinition, + { + find: (call) => this.Find(call), + findBidiStream: (call) => this.FindBidiStream(call), + findClientStream: (call) => this.FindClientStream(call), + findServerStream: (call) => this.FindServerStream(call), + }, + logger, + trace + ) + } + + public abstract Find( + call: grpc.ServerUnaryCall + ): Promise + public abstract FindBidiStream( + call: grpc.ServerDuplexStream + ): Promise + public abstract FindClientStream( + call: grpc.ServerReadableStream + ): Promise + public abstract FindServerStream( + call: grpc.ServerWritableStream + ): Promise + } + + export interface ISimpleTestServiceImplementation { + ForwardParameter: grpc.handleUnaryCall + GetEmptyResult: grpc.handleUnaryCall< + GoogleProtobuf_Empty.IEmpty, + IBigWrapper + > + } + + export const simpleTestServiceDefinition: grpc.ServiceDefinition = + { + ForwardParameter: { + path: '/foo.SimpleTest/ForwardParameter', + requestStream: false, + responseStream: false, + requestSerialize: (request: IBigWrapper) => + BigWrapper.encodePatched(request).finish() as Buffer, + requestDeserialize: BigWrapper.decodePatched, + responseSerialize: (response: IBigWrapper) => + BigWrapper.encodePatched(response).finish() as Buffer, + responseDeserialize: BigWrapper.decodePatched, + }, + GetEmptyResult: { + path: '/foo.SimpleTest/GetEmptyResult', + requestStream: false, + responseStream: false, + requestSerialize: (request: GoogleProtobuf_Empty.IEmpty) => + GoogleProtobuf_Empty.Empty.encodePatched(request).finish() as Buffer, + requestDeserialize: GoogleProtobuf_Empty.Empty.decodePatched, + responseSerialize: (response: IBigWrapper) => + BigWrapper.encodePatched(response).finish() as Buffer, + responseDeserialize: BigWrapper.decodePatched, + }, + } + + export abstract class AbstractSimpleTestService extends joinGRPC.Service { + constructor( + protected readonly logger?: joinGRPC.INoDebugLogger, + trace?: joinGRPC.IServiceTrace + ) { + super( + simpleTestServiceDefinition, + { + forwardParameter: (call) => this.ForwardParameter(call), + getEmptyResult: (call) => this.GetEmptyResult(call), + }, + logger, + trace + ) + } + + public abstract ForwardParameter( + call: grpc.ServerUnaryCall + ): Promise + public abstract GetEmptyResult( + call: grpc.ServerUnaryCall + ): Promise + } + + export interface IUsersClient + extends joinGRPC.IExtendedClient { + /** + * @deprecated + */ + find( + request: IRequest, + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IUnaryRequest + + findBidiStream( + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IBidiStreamRequest + + findClientStream( + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IClientStreamRequest + + findServerStream( + request: IRequest, + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IServerStreamRequest + } + + export class UsersClient + extends joinGRPC.Client + implements IUsersClient + { + constructor( + config: joinGRPC.ISimplifiedClientConfig + ) { + super( + { + ...config, + serviceDefinition: usersServiceDefinition, + credentials: config?.credentials ?? grpc.credentials.createInsecure(), + }, + 'foo.Users' + ) + } + + /** + * @deprecated + */ + public find( + request: IRequest, + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IUnaryRequest { + this.logger?.warn("using deprecated service method 'UsersClient.find'") + return this.makeUnaryRequest('Find', request, metadata, options) + } + + public findBidiStream( + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IBidiStreamRequest { + return this.makeBidiStreamRequest('FindBidiStream', metadata, options) + } + + public findClientStream( + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IClientStreamRequest { + return this.makeClientStreamRequest('FindClientStream', metadata, options) + } + + public findServerStream( + request: IRequest, + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IServerStreamRequest { + return this.makeServerStreamRequest( + 'FindServerStream', + request, + metadata, + options + ) + } + } + + export interface ISimpleTestClient + extends joinGRPC.IExtendedClient< + ISimpleTestServiceImplementation, + 'foo.SimpleTest' + > { + forwardParameter( + request: IBigWrapper, + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IUnaryRequest + + getEmptyResult( + request: GoogleProtobuf_Empty.IEmpty, + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IUnaryRequest + } + + export class SimpleTestClient + extends joinGRPC.Client + implements ISimpleTestClient + { + constructor( + config: joinGRPC.ISimplifiedClientConfig + ) { + super( + { + ...config, + serviceDefinition: simpleTestServiceDefinition, + credentials: config?.credentials ?? grpc.credentials.createInsecure(), + }, + 'foo.SimpleTest' + ) + } + + public forwardParameter( + request: IBigWrapper, + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IUnaryRequest { + return this.makeUnaryRequest( + 'ForwardParameter', + request, + metadata, + options + ) + } + + public getEmptyResult( + request: GoogleProtobuf_Empty.IEmpty, + metadata?: Record, + options?: grpc.CallOptions + ): joinGRPC.IUnaryRequest { + return this.makeUnaryRequest('GetEmptyResult', request, metadata, options) + } + } +} diff --git a/tests/__tests__/generatedRedundant/common/Common.ts b/tests/__tests__/generatedRedundant/common/Common.ts new file mode 100644 index 0000000..315773d --- /dev/null +++ b/tests/__tests__/generatedRedundant/common/Common.ts @@ -0,0 +1,70 @@ +// GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + +import * as protobufjs from 'protobufjs/light' + +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace Common { + interface ConvertibleTo { + asInterface(): T + } + + export interface IOtherPkgMessage { + /** + * @deprecated + */ + firstName?: string + latsName?: string + } + + @protobufjs.Type.d('common_OtherPkgMessage') + export class OtherPkgMessage + extends protobufjs.Message + implements ConvertibleTo, IOtherPkgMessage + { + /** + * @deprecated + */ + @protobufjs.Field.d(1, 'string', 'optional') + public firstName?: string + + @protobufjs.Field.d(2, 'string', 'optional') + public latsName?: string + + public asInterface(): IOtherPkgMessage { + const message = { + ...this, + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof IOtherPkgMessage] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof IOtherPkgMessage] + } + } + return message + } + + public static fromInterface( + this: void, + value: IOtherPkgMessage + ): OtherPkgMessage { + return OtherPkgMessage.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IOtherPkgMessage { + return OtherPkgMessage.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: IOtherPkgMessage, + writer?: protobufjs.Writer + ): protobufjs.Writer { + return OtherPkgMessage.encode(message, writer) + } + } +} diff --git a/tests/__tests__/generatedRedundant/common/Extra.ts b/tests/__tests__/generatedRedundant/common/Extra.ts new file mode 100644 index 0000000..ee786c3 --- /dev/null +++ b/tests/__tests__/generatedRedundant/common/Extra.ts @@ -0,0 +1,95 @@ +// GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + +import * as protobufjs from 'protobufjs/light' + +import { GoogleProtobuf } from '../google/protobuf/Timestamp' + +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace Common { + interface ConvertibleTo { + asInterface(): T + } + + export interface IExtraPkgMessage { + /** + * @deprecated + */ + firstName?: string + lastName?: string + birthDate?: Date + } + + @protobufjs.Type.d('common_ExtraPkgMessage') + export class ExtraPkgMessage + extends protobufjs.Message + implements ConvertibleTo + { + /** + * @deprecated + */ + @protobufjs.Field.d(1, 'string', 'optional') + public firstName?: string + + @protobufjs.Field.d(2, 'string', 'optional') + public lastName?: string + + @protobufjs.Field.d(3, GoogleProtobuf.Timestamp, 'optional') + public birthDate?: GoogleProtobuf.Timestamp + + public asInterface(): IExtraPkgMessage { + const message = { + ...this, + birthDate: + this.birthDate != null + ? new Date( + (this.birthDate.seconds ?? 0) * 1000 + + (this.birthDate.nanos ?? 0) / 1000000 + ) + : undefined, + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof IExtraPkgMessage] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof IExtraPkgMessage] + } + } + return message + } + + public static fromInterface( + this: void, + value: IExtraPkgMessage + ): ExtraPkgMessage { + const patchedValue = { + ...value, + birthDate: + value.birthDate != null + ? GoogleProtobuf.Timestamp.fromInterface({ + seconds: Math.floor(value.birthDate.getTime() / 1000), + nanos: value.birthDate.getMilliseconds() * 1000000, + }) + : undefined, + } + + return ExtraPkgMessage.fromObject(patchedValue) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IExtraPkgMessage { + return ExtraPkgMessage.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: IExtraPkgMessage, + writer?: protobufjs.Writer + ): protobufjs.Writer { + const transformedMessage = ExtraPkgMessage.fromInterface(message) + return ExtraPkgMessage.encode(transformedMessage, writer) + } + } +} diff --git a/tests/__tests__/generatedRedundant/google/protobuf/Empty.ts b/tests/__tests__/generatedRedundant/google/protobuf/Empty.ts new file mode 100644 index 0000000..789321f --- /dev/null +++ b/tests/__tests__/generatedRedundant/google/protobuf/Empty.ts @@ -0,0 +1,52 @@ +// GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + +import * as protobufjs from 'protobufjs/light' + +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace GoogleProtobuf { + interface ConvertibleTo { + asInterface(): T + } + + export interface IEmpty {} + + @protobufjs.Type.d('google_protobuf_Empty') + export class Empty + extends protobufjs.Message + implements ConvertibleTo, IEmpty + { + public asInterface(): IEmpty { + const message = { + ...this, + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof IEmpty] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof IEmpty] + } + } + return message + } + + public static fromInterface(this: void, value: IEmpty): Empty { + return Empty.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): IEmpty { + return Empty.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: IEmpty, + writer?: protobufjs.Writer + ): protobufjs.Writer { + return Empty.encode(message, writer) + } + } +} diff --git a/tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts b/tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts new file mode 100644 index 0000000..f38d0a4 --- /dev/null +++ b/tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts @@ -0,0 +1,61 @@ +// GENERATED CODE -- DO NOT EDIT! +// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +/* eslint-disable @typescript-eslint/no-non-null-assertion */ + +import * as protobufjs from 'protobufjs/light' + +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace GoogleProtobuf { + interface ConvertibleTo { + asInterface(): T + } + + export interface ITimestamp { + seconds?: number + nanos?: number + } + + @protobufjs.Type.d('google_protobuf_Timestamp') + export class Timestamp + extends protobufjs.Message + implements ConvertibleTo, ITimestamp + { + @protobufjs.Field.d(1, 'int64', 'optional') + public seconds?: number + + @protobufjs.Field.d(2, 'int32', 'optional') + public nanos?: number + + public asInterface(): ITimestamp { + const message = { + ...this, + } + for (const fieldName of Object.keys(message)) { + if (message[fieldName as keyof ITimestamp] == null) { + // We remove the key to avoid problems with code making too many assumptions + delete message[fieldName as keyof ITimestamp] + } + } + return message + } + + public static fromInterface(this: void, value: ITimestamp): Timestamp { + return Timestamp.fromObject(value) + } + + public static decodePatched( + this: void, + reader: protobufjs.Reader | Uint8Array + ): ITimestamp { + return Timestamp.decode(reader).asInterface() + } + + public static encodePatched( + this: void, + message: ITimestamp, + writer?: protobufjs.Writer + ): protobufjs.Writer { + return Timestamp.encode(message, writer) + } + } +} diff --git a/tests/package.json b/tests/package.json index 0027e74..be7d78c 100644 --- a/tests/package.json +++ b/tests/package.json @@ -9,10 +9,11 @@ "lint:eslint": "eslint . --ext .ts --max-warnings 0", "lint:tsc": "tsc --noEmit && eslint", "test": "export PATH=\"${PWD}/../dist:${PATH}\" && jest --runInBand --forceExit", - "proto:build": "yarn proto:clean && yarn proto:generate && yarn proto:prettier", + "proto:build": "yarn proto:clean && yarn proto:generate && yarn proto:prettier && yarn proto:clone", "proto:clean": "find __tests__/generated ! -name 'tslint.json' ! -name '.prettierrc' -type f -exec rm -f {} +", "proto:generate": "export PATH=\"${PWD}/../dist:${PATH}\" && protoc __tests__/proto/*.proto -I __tests__/proto --tsx_out=\"${PWD}/__tests__/generated\"", - "proto:prettier": "prettier --write '__tests__/generated/**/*.ts'" + "proto:prettier": "prettier --write '__tests__/generated/**/*.ts'", + "proto:clone": "rm -rf __tests__/generatedRedundant && cp -R __tests__/generated __tests__/generatedRedundant && echo 'For regression tests' > __tests__/generatedRedundant/README" }, "dependencies": { "@coderspirit/nominal": "^3.0.0", From 01f8bf9adafb08608d6d4df0f3f2ad01f7f3e910 Mon Sep 17 00:00:00 2001 From: Andres Correa Casablanca Date: Mon, 18 Oct 2021 12:37:19 +0200 Subject: [PATCH 5/6] fix: avoid duplicate grpc class registration --- internal/generator/runner_generate.go | 22 +++++++++++++++ internal/generator/runner_generate_class.go | 2 +- tests/__tests__/generated/Flavors.ts | 20 +++++++++++-- tests/__tests__/generated/Regressions.ts | 24 ++++++++++++---- tests/__tests__/generated/Test.ts | 28 ++++++++++++++----- tests/__tests__/generated/common/Common.ts | 18 ++++++++++-- tests/__tests__/generated/common/Extra.ts | 18 ++++++++++-- .../generated/google/protobuf/Empty.ts | 18 ++++++++++-- .../generated/google/protobuf/Timestamp.ts | 18 ++++++++++-- tests/__tests__/generatedRedundant/Flavors.ts | 20 +++++++++++-- .../generatedRedundant/Regressions.ts | 24 ++++++++++++---- tests/__tests__/generatedRedundant/Test.ts | 28 ++++++++++++++----- .../generatedRedundant/common/Common.ts | 18 ++++++++++-- .../generatedRedundant/common/Extra.ts | 18 ++++++++++-- .../google/protobuf/Empty.ts | 18 ++++++++++-- .../google/protobuf/Timestamp.ts | 18 ++++++++++-- ...ressions.test.ts => regressions01.test.ts} | 2 +- tests/__tests__/regressions03.test.ts | 14 ++++++++++ 18 files changed, 280 insertions(+), 48 deletions(-) rename tests/__tests__/{regressions.test.ts => regressions01.test.ts} (99%) create mode 100644 tests/__tests__/regressions03.test.ts diff --git a/internal/generator/runner_generate.go b/internal/generator/runner_generate.go index dbbbb03..d821a41 100644 --- a/internal/generator/runner_generate.go +++ b/internal/generator/runner_generate.go @@ -123,6 +123,8 @@ func (r *Runner) generateTypescriptNamespace(generatedFileStream *protogen.Gener ) r.indentLevel += 2 + r.generateTypescriptClassDecoratorDefinition(generatedFileStream, protoFile) + // This interface is namespace-private, as it's being replicated for every generated file r.P( generatedFileStream, @@ -144,6 +146,26 @@ func (r *Runner) generateTypescriptNamespace(generatedFileStream *protogen.Gener r.P(generatedFileStream, "\n}") } +func (r *Runner) generateTypescriptClassDecoratorDefinition(generatedFileStream *protogen.GeneratedFile, protoFile *protogen.File) { + r.P( + generatedFileStream, + "const registerGrpcClass = >(", + " typeName: string", + "): protobufjs.TypeDecorator => {", + " if (protobufjs.util.decorateRoot.get(typeName) != null) {", + " // eslint-disable-next-line @typescript-eslint/ban-types", + " return (", + " // eslint-disable-next-line @typescript-eslint/no-unused-vars", + " _: protobufjs.Constructor", + " ): void => {", + " // Do nothing", + " }", + " }", + " return protobufjs.Type.d(typeName)", + "}", + ) +} + func (r *Runner) generateTypescriptFlavors(generatedFileStream *protogen.GeneratedFile, protoFile *protogen.File) { flavorBaseTypesMap := make(map[string]string) flavorDeclarations := make([]string, 0) diff --git a/internal/generator/runner_generate_class.go b/internal/generator/runner_generate_class.go index c48dc32..ccf2111 100644 --- a/internal/generator/runner_generate_class.go +++ b/internal/generator/runner_generate_class.go @@ -132,7 +132,7 @@ func (r *Runner) generateTypescriptMessageClass(generatedFileStream *protogen.Ge } r.P( generatedFileStream, - "@protobufjs.Type.d('"+strings.Replace(r.currentPackage, ".", "_", -1)+"_"+className+"')", + "@registerGrpcClass('"+strings.Replace(r.currentPackage, ".", "_", -1)+"_"+className+"')", "export class "+className+" extends protobufjs.Message<"+className+"> implements "+implementedInterfaces+" {\n", ) r.indentLevel += 2 diff --git a/tests/__tests__/generated/Flavors.ts b/tests/__tests__/generated/Flavors.ts index 396b156..5876bd2 100644 --- a/tests/__tests__/generated/Flavors.ts +++ b/tests/__tests__/generated/Flavors.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as joinGRPC from '@join-com/grpc' @@ -11,6 +11,20 @@ import { grpc } from '@join-com/grpc' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace Flavors { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -28,7 +42,7 @@ export namespace Flavors { emails: Email[] } - @protobufjs.Type.d('flavors_UserProfile') + @registerGrpcClass('flavors_UserProfile') export class UserProfile extends protobufjs.Message implements ConvertibleTo, IUserProfile @@ -101,7 +115,7 @@ export namespace Flavors { } } - @protobufjs.Type.d('flavors_UserRequest') + @registerGrpcClass('flavors_UserRequest') export class UserRequest extends protobufjs.Message implements ConvertibleTo, IUserRequest diff --git a/tests/__tests__/generated/Regressions.ts b/tests/__tests__/generated/Regressions.ts index 94eabf4..ec7349a 100644 --- a/tests/__tests__/generated/Regressions.ts +++ b/tests/__tests__/generated/Regressions.ts @@ -1,11 +1,25 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace Regressions { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -40,7 +54,7 @@ export namespace Regressions { /** * @deprecated */ - @protobufjs.Type.d('regressions_DeprecatedMessageWithDeprecatedField') + @registerGrpcClass('regressions_DeprecatedMessageWithDeprecatedField') export class DeprecatedMessageWithDeprecatedField extends protobufjs.Message implements @@ -97,7 +111,7 @@ export namespace Regressions { } } - @protobufjs.Type.d('regressions_MessageWithDeprecatedField') + @registerGrpcClass('regressions_MessageWithDeprecatedField') export class MessageWithDeprecatedField extends protobufjs.Message implements @@ -149,7 +163,7 @@ export namespace Regressions { } } - @protobufjs.Type.d('regressions_Reg01Inner') + @registerGrpcClass('regressions_Reg01Inner') export class Reg01Inner extends protobufjs.Message implements ConvertibleTo, IReg01Inner @@ -190,7 +204,7 @@ export namespace Regressions { } } - @protobufjs.Type.d('regressions_Reg01Outer') + @registerGrpcClass('regressions_Reg01Outer') export class Reg01Outer extends protobufjs.Message implements ConvertibleTo, IReg01Outer diff --git a/tests/__tests__/generated/Test.ts b/tests/__tests__/generated/Test.ts index 731fe10..c4193bd 100644 --- a/tests/__tests__/generated/Test.ts +++ b/tests/__tests__/generated/Test.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as joinGRPC from '@join-com/grpc' @@ -14,6 +14,20 @@ import { grpc } from '@join-com/grpc' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace Foo { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -102,7 +116,7 @@ export namespace Foo { optionalField?: number } - @protobufjs.Type.d('foo_CustomOptionsTest') + @registerGrpcClass('foo_CustomOptionsTest') export class CustomOptionsTest extends protobufjs.Message implements ConvertibleTo @@ -183,7 +197,7 @@ export namespace Foo { /** * @deprecated */ - @protobufjs.Type.d('foo_Nested') + @registerGrpcClass('foo_Nested') export class Nested extends protobufjs.Message implements ConvertibleTo, INested @@ -224,7 +238,7 @@ export namespace Foo { } } - @protobufjs.Type.d('foo_Request') + @registerGrpcClass('foo_Request') export class Request extends protobufjs.Message implements ConvertibleTo, IRequest @@ -265,7 +279,7 @@ export namespace Foo { } } - @protobufjs.Type.d('foo_RequiredPropertiesTest') + @registerGrpcClass('foo_RequiredPropertiesTest') export class RequiredPropertiesTest extends protobufjs.Message implements ConvertibleTo, IRequiredPropertiesTest @@ -336,7 +350,7 @@ export namespace Foo { } } - @protobufjs.Type.d('foo_Test') + @registerGrpcClass('foo_Test') export class Test extends protobufjs.Message implements ConvertibleTo @@ -536,7 +550,7 @@ export namespace Foo { } } - @protobufjs.Type.d('foo_BigWrapper') + @registerGrpcClass('foo_BigWrapper') export class BigWrapper extends protobufjs.Message implements ConvertibleTo diff --git a/tests/__tests__/generated/common/Common.ts b/tests/__tests__/generated/common/Common.ts index 315773d..36d2215 100644 --- a/tests/__tests__/generated/common/Common.ts +++ b/tests/__tests__/generated/common/Common.ts @@ -1,11 +1,25 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace Common { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -18,7 +32,7 @@ export namespace Common { latsName?: string } - @protobufjs.Type.d('common_OtherPkgMessage') + @registerGrpcClass('common_OtherPkgMessage') export class OtherPkgMessage extends protobufjs.Message implements ConvertibleTo, IOtherPkgMessage diff --git a/tests/__tests__/generated/common/Extra.ts b/tests/__tests__/generated/common/Extra.ts index ee786c3..ffd3bfe 100644 --- a/tests/__tests__/generated/common/Extra.ts +++ b/tests/__tests__/generated/common/Extra.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' @@ -8,6 +8,20 @@ import { GoogleProtobuf } from '../google/protobuf/Timestamp' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace Common { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -21,7 +35,7 @@ export namespace Common { birthDate?: Date } - @protobufjs.Type.d('common_ExtraPkgMessage') + @registerGrpcClass('common_ExtraPkgMessage') export class ExtraPkgMessage extends protobufjs.Message implements ConvertibleTo diff --git a/tests/__tests__/generated/google/protobuf/Empty.ts b/tests/__tests__/generated/google/protobuf/Empty.ts index 789321f..628f993 100644 --- a/tests/__tests__/generated/google/protobuf/Empty.ts +++ b/tests/__tests__/generated/google/protobuf/Empty.ts @@ -1,18 +1,32 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace GoogleProtobuf { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } export interface IEmpty {} - @protobufjs.Type.d('google_protobuf_Empty') + @registerGrpcClass('google_protobuf_Empty') export class Empty extends protobufjs.Message implements ConvertibleTo, IEmpty diff --git a/tests/__tests__/generated/google/protobuf/Timestamp.ts b/tests/__tests__/generated/google/protobuf/Timestamp.ts index f38d0a4..5c6d989 100644 --- a/tests/__tests__/generated/google/protobuf/Timestamp.ts +++ b/tests/__tests__/generated/google/protobuf/Timestamp.ts @@ -1,11 +1,25 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace GoogleProtobuf { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -15,7 +29,7 @@ export namespace GoogleProtobuf { nanos?: number } - @protobufjs.Type.d('google_protobuf_Timestamp') + @registerGrpcClass('google_protobuf_Timestamp') export class Timestamp extends protobufjs.Message implements ConvertibleTo, ITimestamp diff --git a/tests/__tests__/generatedRedundant/Flavors.ts b/tests/__tests__/generatedRedundant/Flavors.ts index 396b156..5876bd2 100644 --- a/tests/__tests__/generatedRedundant/Flavors.ts +++ b/tests/__tests__/generatedRedundant/Flavors.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as joinGRPC from '@join-com/grpc' @@ -11,6 +11,20 @@ import { grpc } from '@join-com/grpc' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace Flavors { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -28,7 +42,7 @@ export namespace Flavors { emails: Email[] } - @protobufjs.Type.d('flavors_UserProfile') + @registerGrpcClass('flavors_UserProfile') export class UserProfile extends protobufjs.Message implements ConvertibleTo, IUserProfile @@ -101,7 +115,7 @@ export namespace Flavors { } } - @protobufjs.Type.d('flavors_UserRequest') + @registerGrpcClass('flavors_UserRequest') export class UserRequest extends protobufjs.Message implements ConvertibleTo, IUserRequest diff --git a/tests/__tests__/generatedRedundant/Regressions.ts b/tests/__tests__/generatedRedundant/Regressions.ts index 94eabf4..ec7349a 100644 --- a/tests/__tests__/generatedRedundant/Regressions.ts +++ b/tests/__tests__/generatedRedundant/Regressions.ts @@ -1,11 +1,25 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace Regressions { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -40,7 +54,7 @@ export namespace Regressions { /** * @deprecated */ - @protobufjs.Type.d('regressions_DeprecatedMessageWithDeprecatedField') + @registerGrpcClass('regressions_DeprecatedMessageWithDeprecatedField') export class DeprecatedMessageWithDeprecatedField extends protobufjs.Message implements @@ -97,7 +111,7 @@ export namespace Regressions { } } - @protobufjs.Type.d('regressions_MessageWithDeprecatedField') + @registerGrpcClass('regressions_MessageWithDeprecatedField') export class MessageWithDeprecatedField extends protobufjs.Message implements @@ -149,7 +163,7 @@ export namespace Regressions { } } - @protobufjs.Type.d('regressions_Reg01Inner') + @registerGrpcClass('regressions_Reg01Inner') export class Reg01Inner extends protobufjs.Message implements ConvertibleTo, IReg01Inner @@ -190,7 +204,7 @@ export namespace Regressions { } } - @protobufjs.Type.d('regressions_Reg01Outer') + @registerGrpcClass('regressions_Reg01Outer') export class Reg01Outer extends protobufjs.Message implements ConvertibleTo, IReg01Outer diff --git a/tests/__tests__/generatedRedundant/Test.ts b/tests/__tests__/generatedRedundant/Test.ts index 731fe10..c4193bd 100644 --- a/tests/__tests__/generatedRedundant/Test.ts +++ b/tests/__tests__/generatedRedundant/Test.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as joinGRPC from '@join-com/grpc' @@ -14,6 +14,20 @@ import { grpc } from '@join-com/grpc' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace Foo { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -102,7 +116,7 @@ export namespace Foo { optionalField?: number } - @protobufjs.Type.d('foo_CustomOptionsTest') + @registerGrpcClass('foo_CustomOptionsTest') export class CustomOptionsTest extends protobufjs.Message implements ConvertibleTo @@ -183,7 +197,7 @@ export namespace Foo { /** * @deprecated */ - @protobufjs.Type.d('foo_Nested') + @registerGrpcClass('foo_Nested') export class Nested extends protobufjs.Message implements ConvertibleTo, INested @@ -224,7 +238,7 @@ export namespace Foo { } } - @protobufjs.Type.d('foo_Request') + @registerGrpcClass('foo_Request') export class Request extends protobufjs.Message implements ConvertibleTo, IRequest @@ -265,7 +279,7 @@ export namespace Foo { } } - @protobufjs.Type.d('foo_RequiredPropertiesTest') + @registerGrpcClass('foo_RequiredPropertiesTest') export class RequiredPropertiesTest extends protobufjs.Message implements ConvertibleTo, IRequiredPropertiesTest @@ -336,7 +350,7 @@ export namespace Foo { } } - @protobufjs.Type.d('foo_Test') + @registerGrpcClass('foo_Test') export class Test extends protobufjs.Message implements ConvertibleTo @@ -536,7 +550,7 @@ export namespace Foo { } } - @protobufjs.Type.d('foo_BigWrapper') + @registerGrpcClass('foo_BigWrapper') export class BigWrapper extends protobufjs.Message implements ConvertibleTo diff --git a/tests/__tests__/generatedRedundant/common/Common.ts b/tests/__tests__/generatedRedundant/common/Common.ts index 315773d..36d2215 100644 --- a/tests/__tests__/generatedRedundant/common/Common.ts +++ b/tests/__tests__/generatedRedundant/common/Common.ts @@ -1,11 +1,25 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace Common { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -18,7 +32,7 @@ export namespace Common { latsName?: string } - @protobufjs.Type.d('common_OtherPkgMessage') + @registerGrpcClass('common_OtherPkgMessage') export class OtherPkgMessage extends protobufjs.Message implements ConvertibleTo, IOtherPkgMessage diff --git a/tests/__tests__/generatedRedundant/common/Extra.ts b/tests/__tests__/generatedRedundant/common/Extra.ts index ee786c3..ffd3bfe 100644 --- a/tests/__tests__/generatedRedundant/common/Extra.ts +++ b/tests/__tests__/generatedRedundant/common/Extra.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' @@ -8,6 +8,20 @@ import { GoogleProtobuf } from '../google/protobuf/Timestamp' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace Common { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -21,7 +35,7 @@ export namespace Common { birthDate?: Date } - @protobufjs.Type.d('common_ExtraPkgMessage') + @registerGrpcClass('common_ExtraPkgMessage') export class ExtraPkgMessage extends protobufjs.Message implements ConvertibleTo diff --git a/tests/__tests__/generatedRedundant/google/protobuf/Empty.ts b/tests/__tests__/generatedRedundant/google/protobuf/Empty.ts index 789321f..628f993 100644 --- a/tests/__tests__/generatedRedundant/google/protobuf/Empty.ts +++ b/tests/__tests__/generatedRedundant/google/protobuf/Empty.ts @@ -1,18 +1,32 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace GoogleProtobuf { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } export interface IEmpty {} - @protobufjs.Type.d('google_protobuf_Empty') + @registerGrpcClass('google_protobuf_Empty') export class Empty extends protobufjs.Message implements ConvertibleTo, IEmpty diff --git a/tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts b/tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts index f38d0a4..5c6d989 100644 --- a/tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts +++ b/tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts @@ -1,11 +1,25 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.c3b10e1.1634550238 +// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' // eslint-disable-next-line @typescript-eslint/no-namespace export namespace GoogleProtobuf { + const registerGrpcClass = >( + typeName: string + ): protobufjs.TypeDecorator => { + if (protobufjs.util.decorateRoot.get(typeName) != null) { + // eslint-disable-next-line @typescript-eslint/ban-types + return ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _: protobufjs.Constructor + ): void => { + // Do nothing + } + } + return protobufjs.Type.d(typeName) + } interface ConvertibleTo { asInterface(): T } @@ -15,7 +29,7 @@ export namespace GoogleProtobuf { nanos?: number } - @protobufjs.Type.d('google_protobuf_Timestamp') + @registerGrpcClass('google_protobuf_Timestamp') export class Timestamp extends protobufjs.Message implements ConvertibleTo, ITimestamp diff --git a/tests/__tests__/regressions.test.ts b/tests/__tests__/regressions01.test.ts similarity index 99% rename from tests/__tests__/regressions.test.ts rename to tests/__tests__/regressions01.test.ts index 9f45554..29e3680 100644 --- a/tests/__tests__/regressions.test.ts +++ b/tests/__tests__/regressions01.test.ts @@ -7,7 +7,7 @@ import { Regressions } from './generated/Regressions' import { parse as parseComment } from 'comment-parser' import { join as pathJoin } from 'path' -describe('regressions', () => { +describe('regressions 01-02', () => { it('01. decodes missing nested fields as undefined when there are no enums', () => { // Background: before this test was written, calling .asInterface() for nested objects was // done only when there were enum fields at some level of the object. diff --git a/tests/__tests__/regressions03.test.ts b/tests/__tests__/regressions03.test.ts new file mode 100644 index 0000000..caaf707 --- /dev/null +++ b/tests/__tests__/regressions03.test.ts @@ -0,0 +1,14 @@ +// The real test is here: we want to ensure that redundant imports don't cause an error. +import { GoogleProtobuf as gp1 } from './generated/google/protobuf/Timestamp' +import { GoogleProtobuf as gp2 } from './generatedRedundant/google/protobuf/Timestamp' + +describe('regressions 03', () => { + it('dummy test', () => { + // This test has code only to ensure that the linters don't complain because of unused imports. + const _ts1 = gp1.Timestamp.fromInterface({ seconds: 0, nanos: 0 }) + const _ts2 = gp2.Timestamp.fromInterface({ seconds: 0, nanos: 0 }) + + expect(_ts1.asInterface().seconds).toEqual(_ts2.asInterface().seconds) + expect(_ts1.asInterface().nanos).toEqual(_ts2.asInterface().nanos) + }) +}) From 51a431dc3dea37cd79f0821c3ba7a9f9f5406edb Mon Sep 17 00:00:00 2001 From: Andres Correa Casablanca Date: Mon, 18 Oct 2021 12:38:02 +0200 Subject: [PATCH 6/6] chore: update version in generated files --- tests/__tests__/generated/Flavors.ts | 2 +- tests/__tests__/generated/Regressions.ts | 2 +- tests/__tests__/generated/Test.ts | 2 +- tests/__tests__/generated/common/Common.ts | 2 +- tests/__tests__/generated/common/Extra.ts | 2 +- tests/__tests__/generated/google/protobuf/Empty.ts | 2 +- tests/__tests__/generated/google/protobuf/Timestamp.ts | 2 +- tests/__tests__/generatedRedundant/Flavors.ts | 2 +- tests/__tests__/generatedRedundant/Regressions.ts | 2 +- tests/__tests__/generatedRedundant/Test.ts | 2 +- tests/__tests__/generatedRedundant/common/Common.ts | 2 +- tests/__tests__/generatedRedundant/common/Extra.ts | 2 +- tests/__tests__/generatedRedundant/google/protobuf/Empty.ts | 2 +- tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/__tests__/generated/Flavors.ts b/tests/__tests__/generated/Flavors.ts index 5876bd2..0d96d6b 100644 --- a/tests/__tests__/generated/Flavors.ts +++ b/tests/__tests__/generated/Flavors.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as joinGRPC from '@join-com/grpc' diff --git a/tests/__tests__/generated/Regressions.ts b/tests/__tests__/generated/Regressions.ts index ec7349a..3a3581d 100644 --- a/tests/__tests__/generated/Regressions.ts +++ b/tests/__tests__/generated/Regressions.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generated/Test.ts b/tests/__tests__/generated/Test.ts index c4193bd..ae10b8c 100644 --- a/tests/__tests__/generated/Test.ts +++ b/tests/__tests__/generated/Test.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as joinGRPC from '@join-com/grpc' diff --git a/tests/__tests__/generated/common/Common.ts b/tests/__tests__/generated/common/Common.ts index 36d2215..d342b31 100644 --- a/tests/__tests__/generated/common/Common.ts +++ b/tests/__tests__/generated/common/Common.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generated/common/Extra.ts b/tests/__tests__/generated/common/Extra.ts index ffd3bfe..ac6dfd1 100644 --- a/tests/__tests__/generated/common/Extra.ts +++ b/tests/__tests__/generated/common/Extra.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generated/google/protobuf/Empty.ts b/tests/__tests__/generated/google/protobuf/Empty.ts index 628f993..7b6187c 100644 --- a/tests/__tests__/generated/google/protobuf/Empty.ts +++ b/tests/__tests__/generated/google/protobuf/Empty.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generated/google/protobuf/Timestamp.ts b/tests/__tests__/generated/google/protobuf/Timestamp.ts index 5c6d989..a9616aa 100644 --- a/tests/__tests__/generated/google/protobuf/Timestamp.ts +++ b/tests/__tests__/generated/google/protobuf/Timestamp.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generatedRedundant/Flavors.ts b/tests/__tests__/generatedRedundant/Flavors.ts index 5876bd2..0d96d6b 100644 --- a/tests/__tests__/generatedRedundant/Flavors.ts +++ b/tests/__tests__/generatedRedundant/Flavors.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as joinGRPC from '@join-com/grpc' diff --git a/tests/__tests__/generatedRedundant/Regressions.ts b/tests/__tests__/generatedRedundant/Regressions.ts index ec7349a..3a3581d 100644 --- a/tests/__tests__/generatedRedundant/Regressions.ts +++ b/tests/__tests__/generatedRedundant/Regressions.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generatedRedundant/Test.ts b/tests/__tests__/generatedRedundant/Test.ts index c4193bd..ae10b8c 100644 --- a/tests/__tests__/generatedRedundant/Test.ts +++ b/tests/__tests__/generatedRedundant/Test.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as joinGRPC from '@join-com/grpc' diff --git a/tests/__tests__/generatedRedundant/common/Common.ts b/tests/__tests__/generatedRedundant/common/Common.ts index 36d2215..d342b31 100644 --- a/tests/__tests__/generatedRedundant/common/Common.ts +++ b/tests/__tests__/generatedRedundant/common/Common.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generatedRedundant/common/Extra.ts b/tests/__tests__/generatedRedundant/common/Extra.ts index ffd3bfe..ac6dfd1 100644 --- a/tests/__tests__/generatedRedundant/common/Extra.ts +++ b/tests/__tests__/generatedRedundant/common/Extra.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generatedRedundant/google/protobuf/Empty.ts b/tests/__tests__/generatedRedundant/google/protobuf/Empty.ts index 628f993..7b6187c 100644 --- a/tests/__tests__/generatedRedundant/google/protobuf/Empty.ts +++ b/tests/__tests__/generatedRedundant/google/protobuf/Empty.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light' diff --git a/tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts b/tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts index 5c6d989..a9616aa 100644 --- a/tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts +++ b/tests/__tests__/generatedRedundant/google/protobuf/Timestamp.ts @@ -1,5 +1,5 @@ // GENERATED CODE -- DO NOT EDIT! -// GENERATOR VERSION: 2.1.0.0758bd7.1634553278 +// GENERATOR VERSION: 2.1.0.c2c6dc6.1634553468 /* eslint-disable @typescript-eslint/no-non-null-assertion */ import * as protobufjs from 'protobufjs/light'