ts-proto 1.110.2 → 1.110.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.110.3](https://github.com/stephenh/ts-proto/compare/v1.110.2...v1.110.3) (2022-04-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * regression in being able to return a Date as a GRPC return value ([#534](https://github.com/stephenh/ts-proto/issues/534)) ([22b76ec](https://github.com/stephenh/ts-proto/commit/22b76eccfc0d26309aab9e454de31ef020595be8))
7
+
1
8
  ## [1.110.2](https://github.com/stephenh/ts-proto/compare/v1.110.1...v1.110.2) (2022-03-27)
2
9
 
3
10
 
@@ -75,15 +75,19 @@ function generateService(ctx, fileDesc, sourceInfo, serviceDesc) {
75
75
  exports.generateService = generateService;
76
76
  function generateRegularRpcMethod(ctx, fileDesc, serviceDesc, methodDesc) {
77
77
  utils_1.assertInstanceOf(methodDesc, utils_1.FormattedMethodDescriptor);
78
- const { options } = ctx;
78
+ const { options, utils } = ctx;
79
79
  const Reader = ts_poet_1.imp('Reader@protobufjs/minimal');
80
80
  const rawInputType = types_1.rawRequestType(ctx, methodDesc);
81
81
  const inputType = types_1.requestType(ctx, methodDesc);
82
82
  const outputType = types_1.responseType(ctx, methodDesc);
83
+ const rawOutputType = types_1.responseType(ctx, methodDesc, { keepValueType: true });
83
84
  const params = [...(options.context ? [ts_poet_1.code `ctx: Context`] : []), ts_poet_1.code `request: ${inputType}`];
84
85
  const maybeCtx = options.context ? 'ctx,' : '';
85
86
  let encode = ts_poet_1.code `${rawInputType}.encode(request).finish()`;
86
87
  let decode = ts_poet_1.code `data => ${outputType}.decode(new ${Reader}(data))`;
88
+ if (options.useDate && rawOutputType.toString().includes('Timestamp')) {
89
+ decode = ts_poet_1.code `data => ${utils.fromTimestamp}(${rawOutputType}.decode(new ${Reader}(data)))`;
90
+ }
87
91
  if (methodDesc.clientStreaming) {
88
92
  encode = ts_poet_1.code `request.pipe(${ts_poet_1.imp('map@rxjs/operators')}(request => ${encode}))`;
89
93
  }
package/build/types.js CHANGED
@@ -612,8 +612,8 @@ function requestType(ctx, methodDesc, partial = false) {
612
612
  return typeName;
613
613
  }
614
614
  exports.requestType = requestType;
615
- function responseType(ctx, methodDesc) {
616
- return messageToTypeName(ctx, methodDesc.outputType, { keepValueType: true });
615
+ function responseType(ctx, methodDesc, typeOptions = {}) {
616
+ return messageToTypeName(ctx, methodDesc.outputType, typeOptions);
617
617
  }
618
618
  exports.responseType = responseType;
619
619
  function responsePromise(ctx, methodDesc) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.110.2",
3
+ "version": "1.110.3",
4
4
  "description": "",
5
5
  "main": "build/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",