Skip to content

Commit

Permalink
Conflict.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenh committed Dec 14, 2021
2 parents 5c9c53f + 5e30965 commit 6b27525
Show file tree
Hide file tree
Showing 48 changed files with 294 additions and 221 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# [1.94.0](https://github.com/stephenh/ts-proto/compare/v1.93.3...v1.94.0) (2021-12-14)


### Features

* Round numbers in toJSON. ([#444](https://github.com/stephenh/ts-proto/issues/444)) ([bd2df7b](https://github.com/stephenh/ts-proto/commit/bd2df7b7176e961955ed1dcacb3602384e13ee45))

## [1.93.3](https://github.com/stephenh/ts-proto/compare/v1.93.2...v1.93.3) (2021-12-13)


### Bug Fixes

* support mutliple options in snakeToCamel flag ([#429](https://github.com/stephenh/ts-proto/issues/429)) ([cff6674](https://github.com/stephenh/ts-proto/commit/cff667406cba21676546fd91b04cf2cbc571ed7d)), closes [#423](https://github.com/stephenh/ts-proto/issues/423)

## [1.93.2](https://github.com/stephenh/ts-proto/compare/v1.93.1...v1.93.2) (2021-12-09)


Expand Down
4 changes: 1 addition & 3 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,7 @@ Generated code will be placed in the Gradle build directory.

- With `--ts_proto_opt=lowerCaseServiceMethods=true`, the method names of service methods will be lowered/camel-case, i.e. `service.findFoo` instead of `service.FindFoo`.

- With `--ts_proto_opt=snakeToCamel=false`, fields will be kept snake case.

Defaults to `true`.
- With `--ts_proto_opt=snakeToCamel=false`, fields will be kept snake case. `snakeToCamel` can also be set as string with `--ts_proto_opt=snakeToCamel=keys,json`. `keys` will keep field names as camelCase and `json` will keep json field names as camelCase. Empty string will keep field names as snake_case.

- With `--ts_proto_opt=outputEncodeMethods=false`, the `Message.encode` and `Message.decode` methods for working with protobuf-encoded/binary data will not be output.

Expand Down
2 changes: 1 addition & 1 deletion integration/angular/simple-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const SimpleMessage = {

toJSON(message: SimpleMessage): unknown {
const obj: any = {};
message.numberField !== undefined && (obj.numberField = message.numberField);
message.numberField !== undefined && (obj.numberField = Math.round(message.numberField));
return obj;
},

Expand Down
2 changes: 1 addition & 1 deletion integration/avoid-import-conflicts/simple2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const Simple = {
toJSON(message: Simple): unknown {
const obj: any = {};
message.name !== undefined && (obj.name = message.name);
message.age !== undefined && (obj.age = message.age);
message.age !== undefined && (obj.age = Math.round(message.age));
return obj;
},

Expand Down
2 changes: 1 addition & 1 deletion integration/barrel-imports/bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Bar = {
toJSON(message: Bar): unknown {
const obj: any = {};
message.name !== undefined && (obj.name = message.name);
message.age !== undefined && (obj.age = message.age);
message.age !== undefined && (obj.age = Math.round(message.age));
return obj;
},

Expand Down
8 changes: 4 additions & 4 deletions integration/bytes-node/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export const Int64Value = {

toJSON(message: Int64Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -271,7 +271,7 @@ export const UInt64Value = {

toJSON(message: UInt64Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -318,7 +318,7 @@ export const Int32Value = {

toJSON(message: Int32Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -365,7 +365,7 @@ export const UInt32Value = {

toJSON(message: UInt32Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down
4 changes: 2 additions & 2 deletions integration/file-suffix/google/protobuf/timestamp.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ export const Timestamp = {

toJSON(message: Timestamp): unknown {
const obj: any = {};
message.seconds !== undefined && (obj.seconds = message.seconds);
message.nanos !== undefined && (obj.nanos = message.nanos);
message.seconds !== undefined && (obj.seconds = Math.round(message.seconds));
message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
return obj;
},

Expand Down
4 changes: 2 additions & 2 deletions integration/grpc-js/google/protobuf/timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ export const Timestamp = {

toJSON(message: Timestamp): unknown {
const obj: any = {};
message.seconds !== undefined && (obj.seconds = message.seconds);
message.nanos !== undefined && (obj.nanos = message.nanos);
message.seconds !== undefined && (obj.seconds = Math.round(message.seconds));
message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
return obj;
},

Expand Down
8 changes: 4 additions & 4 deletions integration/grpc-js/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export const Int64Value = {

toJSON(message: Int64Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -271,7 +271,7 @@ export const UInt64Value = {

toJSON(message: UInt64Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -318,7 +318,7 @@ export const Int32Value = {

toJSON(message: Int32Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -365,7 +365,7 @@ export const UInt32Value = {

toJSON(message: UInt32Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down
2 changes: 1 addition & 1 deletion integration/oneof-properties/oneof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const PleaseChoose = {
(obj.bunchaBytes = message.bunchaBytes !== undefined ? base64FromBytes(message.bunchaBytes) : undefined);
message.anEnum !== undefined &&
(obj.anEnum = message.anEnum !== undefined ? pleaseChoose_StateEnumToJSON(message.anEnum) : undefined);
message.age !== undefined && (obj.age = message.age);
message.age !== undefined && (obj.age = Math.round(message.age));
message.either !== undefined && (obj.either = message.either);
message.or !== undefined && (obj.or = message.or);
message.thirdOption !== undefined && (obj.thirdOption = message.thirdOption);
Expand Down
4 changes: 2 additions & 2 deletions integration/oneof-unions/oneof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export const PleaseChoose = {
message.choice?.$case === 'anEnum' &&
(obj.anEnum =
message.choice?.anEnum !== undefined ? pleaseChoose_StateEnumToJSON(message.choice?.anEnum) : undefined);
message.age !== undefined && (obj.age = message.age);
message.age !== undefined && (obj.age = Math.round(message.age));
message.eitherOr?.$case === 'either' && (obj.either = message.eitherOr?.either);
message.eitherOr?.$case === 'or' && (obj.or = message.eitherOr?.or);
message.eitherOr?.$case === 'thirdOption' && (obj.thirdOption = message.eitherOr?.thirdOption);
Expand Down Expand Up @@ -368,7 +368,7 @@ export const SimpleButOptional = {
toJSON(message: SimpleButOptional): unknown {
const obj: any = {};
message.name !== undefined && (obj.name = message.name);
message.age !== undefined && (obj.age = message.age);
message.age !== undefined && (obj.age = Math.round(message.age));
return obj;
},

Expand Down
2 changes: 1 addition & 1 deletion integration/simple-deprecated-fields/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const Simple = {
toJSON(message: Simple): unknown {
const obj: any = {};
message.name !== undefined && (obj.name = message.name);
message.age !== undefined && (obj.age = message.age);
message.age !== undefined && (obj.age = Math.round(message.age));
message.child !== undefined && (obj.child = message.child ? Child.toJSON(message.child) : undefined);
message.testField !== undefined && (obj.testField = message.testField);
message.testNotDeprecated !== undefined && (obj.testNotDeprecated = message.testNotDeprecated);
Expand Down
22 changes: 11 additions & 11 deletions integration/simple-esmodule-interop/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const Simple = {
toJSON(message: Simple): unknown {
const obj: any = {};
message.name !== undefined && (obj.name = message.name);
message.age !== undefined && (obj.age = message.age);
message.age !== undefined && (obj.age = Math.round(message.age));
return obj;
},

Expand Down Expand Up @@ -208,16 +208,16 @@ export const Numbers = {
const obj: any = {};
message.double !== undefined && (obj.double = message.double);
message.float !== undefined && (obj.float = message.float);
message.int32 !== undefined && (obj.int32 = message.int32);
message.int64 !== undefined && (obj.int64 = message.int64);
message.uint32 !== undefined && (obj.uint32 = message.uint32);
message.uint64 !== undefined && (obj.uint64 = message.uint64);
message.sint32 !== undefined && (obj.sint32 = message.sint32);
message.sint64 !== undefined && (obj.sint64 = message.sint64);
message.fixed32 !== undefined && (obj.fixed32 = message.fixed32);
message.fixed64 !== undefined && (obj.fixed64 = message.fixed64);
message.sfixed32 !== undefined && (obj.sfixed32 = message.sfixed32);
message.sfixed64 !== undefined && (obj.sfixed64 = message.sfixed64);
message.int32 !== undefined && (obj.int32 = Math.round(message.int32));
message.int64 !== undefined && (obj.int64 = Math.round(message.int64));
message.uint32 !== undefined && (obj.uint32 = Math.round(message.uint32));
message.uint64 !== undefined && (obj.uint64 = Math.round(message.uint64));
message.sint32 !== undefined && (obj.sint32 = Math.round(message.sint32));
message.sint64 !== undefined && (obj.sint64 = Math.round(message.sint64));
message.fixed32 !== undefined && (obj.fixed32 = Math.round(message.fixed32));
message.fixed64 !== undefined && (obj.fixed64 = Math.round(message.fixed64));
message.sfixed32 !== undefined && (obj.sfixed32 = Math.round(message.sfixed32));
message.sfixed64 !== undefined && (obj.sfixed64 = Math.round(message.sfixed64));
return obj;
},

Expand Down
4 changes: 2 additions & 2 deletions integration/simple-json-name/google/protobuf/timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ export const Timestamp = {

toJSON(message: Timestamp): unknown {
const obj: any = {};
message.seconds !== undefined && (obj.seconds = message.seconds);
message.nanos !== undefined && (obj.nanos = message.nanos);
message.seconds !== undefined && (obj.seconds = Math.round(message.seconds));
message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
return obj;
},

Expand Down
2 changes: 1 addition & 1 deletion integration/simple-json-name/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const Simple = {
toJSON(message: Simple): unknown {
const obj: any = {};
message.name !== undefined && (obj.other_name = message.name);
message.age !== undefined && (obj.other_age = message.age);
message.age !== undefined && (obj.other_age = Math.round(message.age));
message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
return obj;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const Timestamp = {
toJSON(message: Timestamp): unknown {
const obj: any = {};
message.seconds !== undefined && (obj.seconds = message.seconds);
message.nanos !== undefined && (obj.nanos = message.nanos);
message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
return obj;
},

Expand Down
4 changes: 2 additions & 2 deletions integration/simple-long-string/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export const Int32Value = {

toJSON(message: Int32Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -365,7 +365,7 @@ export const UInt32Value = {

toJSON(message: UInt32Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down
10 changes: 5 additions & 5 deletions integration/simple-long-string/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ export const Numbers = {
const obj: any = {};
message.double !== undefined && (obj.double = message.double);
message.float !== undefined && (obj.float = message.float);
message.int32 !== undefined && (obj.int32 = message.int32);
message.int32 !== undefined && (obj.int32 = Math.round(message.int32));
message.int64 !== undefined && (obj.int64 = message.int64);
message.uint32 !== undefined && (obj.uint32 = message.uint32);
message.uint32 !== undefined && (obj.uint32 = Math.round(message.uint32));
message.uint64 !== undefined && (obj.uint64 = message.uint64);
message.sint32 !== undefined && (obj.sint32 = message.sint32);
message.sint32 !== undefined && (obj.sint32 = Math.round(message.sint32));
message.sint64 !== undefined && (obj.sint64 = message.sint64);
message.fixed32 !== undefined && (obj.fixed32 = message.fixed32);
message.fixed32 !== undefined && (obj.fixed32 = Math.round(message.fixed32));
message.fixed64 !== undefined && (obj.fixed64 = message.fixed64);
message.sfixed32 !== undefined && (obj.sfixed32 = message.sfixed32);
message.sfixed32 !== undefined && (obj.sfixed32 = Math.round(message.sfixed32));
message.sfixed64 !== undefined && (obj.sfixed64 = message.sfixed64);
message.guint64 !== undefined && (obj.guint64 = message.guint64);
message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString());
Expand Down
4 changes: 2 additions & 2 deletions integration/simple-long/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export const Int32Value = {

toJSON(message: Int32Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -365,7 +365,7 @@ export const UInt32Value = {

toJSON(message: UInt32Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down
16 changes: 8 additions & 8 deletions integration/simple-long/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export const SimpleWithMap = {
obj.intLookup = {};
if (message.intLookup) {
Object.entries(message.intLookup).forEach(([k, v]) => {
obj.intLookup[k] = v;
obj.intLookup[k] = Math.round(v);
});
}
obj.longLookup = {};
Expand Down Expand Up @@ -392,8 +392,8 @@ export const SimpleWithMap_IntLookupEntry = {

toJSON(message: SimpleWithMap_IntLookupEntry): unknown {
const obj: any = {};
message.key !== undefined && (obj.key = message.key);
message.value !== undefined && (obj.value = message.value);
message.key !== undefined && (obj.key = Math.round(message.key));
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -612,15 +612,15 @@ export const Numbers = {
const obj: any = {};
message.double !== undefined && (obj.double = message.double);
message.float !== undefined && (obj.float = message.float);
message.int32 !== undefined && (obj.int32 = message.int32);
message.int32 !== undefined && (obj.int32 = Math.round(message.int32));
message.int64 !== undefined && (obj.int64 = (message.int64 || Long.ZERO).toString());
message.uint32 !== undefined && (obj.uint32 = message.uint32);
message.uint32 !== undefined && (obj.uint32 = Math.round(message.uint32));
message.uint64 !== undefined && (obj.uint64 = (message.uint64 || Long.UZERO).toString());
message.sint32 !== undefined && (obj.sint32 = message.sint32);
message.sint32 !== undefined && (obj.sint32 = Math.round(message.sint32));
message.sint64 !== undefined && (obj.sint64 = (message.sint64 || Long.ZERO).toString());
message.fixed32 !== undefined && (obj.fixed32 = message.fixed32);
message.fixed32 !== undefined && (obj.fixed32 = Math.round(message.fixed32));
message.fixed64 !== undefined && (obj.fixed64 = (message.fixed64 || Long.UZERO).toString());
message.sfixed32 !== undefined && (obj.sfixed32 = message.sfixed32);
message.sfixed32 !== undefined && (obj.sfixed32 = Math.round(message.sfixed32));
message.sfixed64 !== undefined && (obj.sfixed64 = (message.sfixed64 || Long.ZERO).toString());
if (message.manyUint64) {
obj.manyUint64 = message.manyUint64.map((e) => (e || Long.UZERO).toString());
Expand Down
4 changes: 2 additions & 2 deletions integration/simple-optionals/google/protobuf/timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ export const Timestamp = {

toJSON(message: Timestamp): unknown {
const obj: any = {};
message.seconds !== undefined && (obj.seconds = message.seconds);
message.nanos !== undefined && (obj.nanos = message.nanos);
message.seconds !== undefined && (obj.seconds = Math.round(message.seconds));
message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
return obj;
},

Expand Down
8 changes: 4 additions & 4 deletions integration/simple-optionals/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export const Int64Value = {

toJSON(message: Int64Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -271,7 +271,7 @@ export const UInt64Value = {

toJSON(message: UInt64Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -318,7 +318,7 @@ export const Int32Value = {

toJSON(message: Int32Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down Expand Up @@ -365,7 +365,7 @@ export const UInt32Value = {

toJSON(message: UInt32Value): unknown {
const obj: any = {};
message.value !== undefined && (obj.value = message.value);
message.value !== undefined && (obj.value = Math.round(message.value));
return obj;
},

Expand Down
Loading

0 comments on commit 6b27525

Please sign in to comment.