ts-proto 2.18.1 → 2.18.2

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/README.markdown CHANGED
@@ -548,7 +548,7 @@ With `--ts_proto_opt=protoJsonFormat=false`, strict proto3 compliance is disable
548
548
 
549
549
  - With `--ts_proto_opt=useJsonWireFormat=true`, the generated code will reflect the JSON representation of Protobuf messages.
550
550
 
551
- Requires `onlyTypes=true`. Implies `useDate=string` and `stringEnums=true`. This option is to generate types that can be directly used with marshalling/unmarshalling Protobuf messages serialized as JSON.
551
+ Requires `onlyTypes=true`. Implies `useDate=string` and `stringEnums=true`, and types `bytes` fields as base64-encoded `string`s. This option is to generate types that can be directly used with marshalling/unmarshalling Protobuf messages serialized as JSON.
552
552
  You may also want to set `useOptionals=all`, as gRPC gateways are not required to send default value for scalar values.
553
553
 
554
554
  - With `--ts_proto_opt=useNumericEnumForJson=true`, the JSON converter (`toJSON`) will encode enum values as int, rather than a string literal.
@@ -138,6 +138,9 @@ function basicTypeName(ctx, field, typeOptions = {}) {
138
138
  if (options.env === options_1.EnvOption.NODE) {
139
139
  return (0, ts_poet_1.code) `Buffer`;
140
140
  }
141
+ else if (options.useJsonWireFormat) {
142
+ return (0, ts_poet_1.code) `string`;
143
+ }
141
144
  else {
142
145
  return (0, ts_poet_1.code) `Uint8Array`;
143
146
  }
@@ -303,6 +306,9 @@ function defaultValue(ctx, field) {
303
306
  if (options.env === options_1.EnvOption.NODE) {
304
307
  return "Buffer.alloc(0)";
305
308
  }
309
+ if (options.useJsonWireFormat) {
310
+ return '""';
311
+ }
306
312
  return "new Uint8Array(0)";
307
313
  case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_MESSAGE:
308
314
  case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_GROUP:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "2.18.1",
3
+ "version": "2.18.2",
4
4
  "description": "",
5
5
  "main": "build/src/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",