ts-proto 2.21.0 → 2.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/main.js +6 -2
- package/package.json +1 -1
package/build/src/main.js
CHANGED
|
@@ -1932,7 +1932,11 @@ function valueTypeFromJson(ctx, field, from) {
|
|
|
1932
1932
|
return (0, ts_poet_1.code) `BigInt(${from})`;
|
|
1933
1933
|
}
|
|
1934
1934
|
else if ((0, types_1.isBytesValueType)(field)) {
|
|
1935
|
-
|
|
1935
|
+
// BytesValue is a base64 string in JSON, like a plain `bytes` field.
|
|
1936
|
+
if (options.env === options_1.EnvOption.NODE) {
|
|
1937
|
+
return (0, ts_poet_1.code) `Buffer.from(${ctx.utils.bytesFromBase64}(${from}))`;
|
|
1938
|
+
}
|
|
1939
|
+
return (0, ts_poet_1.code) `${ctx.utils.bytesFromBase64}(${from})`;
|
|
1936
1940
|
}
|
|
1937
1941
|
else {
|
|
1938
1942
|
return (0, ts_poet_1.code) `${(0, case_1.capitalize)(valueType.toCodeString([]))}(${from})`;
|
|
@@ -2555,7 +2559,7 @@ function generateToJson(ctx, fullName, fullProtobufTypeName, messageDesc) {
|
|
|
2555
2559
|
else if ((0, types_1.isMessage)(field) && !(0, types_1.isValueType)(ctx, field) && !(0, types_1.isMapType)(ctx, messageDesc, field)) {
|
|
2556
2560
|
return (0, ts_poet_1.code) `${(0, types_1.getMessageMethod)(ctx, field.typeName, "toJSON")}(${from})`;
|
|
2557
2561
|
}
|
|
2558
|
-
else if ((0, types_1.isBytes)(field)) {
|
|
2562
|
+
else if ((0, types_1.isBytes)(field) || (0, types_1.isBytesValueType)(field)) {
|
|
2559
2563
|
return (0, ts_poet_1.code) `${utils.base64FromBytes}(${from})`;
|
|
2560
2564
|
}
|
|
2561
2565
|
else if (isLongValueTypeAsObject(options, field)) {
|