ts-proto 1.131.0 → 1.131.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.131.2](https://github.com/stephenh/ts-proto/compare/v1.131.1...v1.131.2) (2022-11-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Adding a failing regression test for wrapper types ([#689](https://github.com/stephenh/ts-proto/issues/689)) ([bde2e28](https://github.com/stephenh/ts-proto/commit/bde2e28ad70bf05ebb21effcdb1caad7217c8291))
7
+
8
+ ## [1.131.1](https://github.com/stephenh/ts-proto/compare/v1.131.0...v1.131.1) (2022-11-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Extend `global.Error` to avoid import collisions with Error proto msgs ([#699](https://github.com/stephenh/ts-proto/issues/699)) ([e9d8f91](https://github.com/stephenh/ts-proto/commit/e9d8f9123b7b3c5e274035fa3f2644b370915181))
14
+
1
15
  # [1.131.0](https://github.com/stephenh/ts-proto/compare/v1.130.0...v1.131.0) (2022-10-25)
2
16
 
3
17
 
@@ -76,17 +76,17 @@ function generateRegularRpcMethod(ctx, fileDesc, serviceDesc, methodDesc) {
76
76
  (0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor);
77
77
  const { options, utils } = ctx;
78
78
  const Reader = (0, utils_1.impFile)(ctx.options, "Reader@protobufjs/minimal");
79
- const rawInputType = (0, types_1.rawRequestType)(ctx, methodDesc);
79
+ const rawInputType = (0, types_1.rawRequestType)(ctx, methodDesc, { keepValueType: true });
80
80
  const inputType = (0, types_1.requestType)(ctx, methodDesc);
81
81
  const outputType = (0, types_1.responseType)(ctx, methodDesc);
82
82
  const rawOutputType = (0, types_1.responseType)(ctx, methodDesc, { keepValueType: true });
83
83
  const params = [...(options.context ? [(0, ts_poet_1.code) `ctx: Context`] : []), (0, ts_poet_1.code) `request: ${inputType}`];
84
84
  const maybeCtx = options.context ? "ctx," : "";
85
85
  let encode = (0, ts_poet_1.code) `${rawInputType}.encode(request).finish()`;
86
- let decode = (0, ts_poet_1.code) `data => ${outputType}.decode(new ${Reader}(data))`;
87
- if (options.useDate && rawOutputType.toString().includes("Timestamp")) {
88
- decode = (0, ts_poet_1.code) `data => ${utils.fromTimestamp}(${rawOutputType}.decode(new ${Reader}(data)))`;
89
- }
86
+ let decode = (0, ts_poet_1.code) `data => ${rawOutputType}.decode(new ${Reader}(data))`;
87
+ // if (options.useDate && rawOutputType.toString().includes("Timestamp")) {
88
+ // decode = code`data => ${utils.fromTimestamp}(${rawOutputType}.decode(new ${Reader}(data)))`;
89
+ // }
90
90
  if (methodDesc.clientStreaming) {
91
91
  if (options.useAsyncIterable) {
92
92
  encode = (0, ts_poet_1.code) `${rawInputType}.encodeTransform(request)`;
package/build/main.js CHANGED
@@ -494,7 +494,7 @@ function makeNiceGrpcServerStreamingMethodResult() {
494
494
  }
495
495
  function makeGrpcWebErrorClass() {
496
496
  const GrpcWebError = (0, ts_poet_1.conditionalOutput)("GrpcWebError", (0, ts_poet_1.code) `
497
- export class GrpcWebError extends Error {
497
+ export class GrpcWebError extends globalThis.Error {
498
498
  constructor(message: string, public code: grpc.Code, public metadata: grpc.Metadata) {
499
499
  super(message);
500
500
  }
package/build/types.js CHANGED
@@ -615,8 +615,8 @@ function detectMapType(ctx, messageDesc, fieldDesc) {
615
615
  return undefined;
616
616
  }
617
617
  exports.detectMapType = detectMapType;
618
- function rawRequestType(ctx, methodDesc) {
619
- return messageToTypeName(ctx, methodDesc.inputType);
618
+ function rawRequestType(ctx, methodDesc, typeOptions = {}) {
619
+ return messageToTypeName(ctx, methodDesc.inputType, typeOptions);
620
620
  }
621
621
  exports.rawRequestType = rawRequestType;
622
622
  function observableType(ctx) {
@@ -627,7 +627,7 @@ function observableType(ctx) {
627
627
  }
628
628
  exports.observableType = observableType;
629
629
  function requestType(ctx, methodDesc, partial = false) {
630
- let typeName = rawRequestType(ctx, methodDesc);
630
+ let typeName = rawRequestType(ctx, methodDesc, { keepValueType: true });
631
631
  if (partial) {
632
632
  typeName = (0, ts_poet_1.code) `${ctx.utils.DeepPartial}<${typeName}>`;
633
633
  }
@@ -638,15 +638,15 @@ function requestType(ctx, methodDesc, partial = false) {
638
638
  }
639
639
  exports.requestType = requestType;
640
640
  function responseType(ctx, methodDesc, typeOptions = {}) {
641
- return messageToTypeName(ctx, methodDesc.outputType, typeOptions);
641
+ return messageToTypeName(ctx, methodDesc.outputType, { keepValueType: true });
642
642
  }
643
643
  exports.responseType = responseType;
644
644
  function responsePromise(ctx, methodDesc) {
645
- return (0, ts_poet_1.code) `Promise<${responseType(ctx, methodDesc)}>`;
645
+ return (0, ts_poet_1.code) `Promise<${responseType(ctx, methodDesc, { keepValueType: true })}>`;
646
646
  }
647
647
  exports.responsePromise = responsePromise;
648
648
  function responseObservable(ctx, methodDesc) {
649
- return (0, ts_poet_1.code) `${observableType(ctx)}<${responseType(ctx, methodDesc)}>`;
649
+ return (0, ts_poet_1.code) `${observableType(ctx)}<${responseType(ctx, methodDesc, { keepValueType: true })}>`;
650
650
  }
651
651
  exports.responseObservable = responseObservable;
652
652
  function responsePromiseOrObservable(ctx, methodDesc) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.131.0",
3
+ "version": "1.131.2",
4
4
  "description": "",
5
5
  "main": "build/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",
@@ -10,15 +10,11 @@
10
10
  "scripts": {
11
11
  "build": "yarn tsc",
12
12
  "build:test": "yarn proto2bin && yarn proto2pbjs && yarn bin2ts",
13
- "build:test:local": "yarn proto2bin:local && yarn proto2pbjs:local && yarn bin2ts:local",
14
13
  "prepare": "yarn build",
15
14
  "proto2bin": "docker compose run --rm protoc update-bins.sh",
16
15
  "proto2bin-node": "docker compose run --rm node update-bins.sh",
17
16
  "proto2pbjs": "docker compose run --rm protoc pbjs.sh",
18
17
  "bin2ts": "docker compose run --rm protoc codegen.sh",
19
- "proto2bin:local": "integration/update-bins.sh",
20
- "proto2pbjs:local": "integration/pbjs.sh",
21
- "bin2ts:local": "integration/codegen.sh",
22
18
  "test": "yarn jest -c jest.config.js --maxWorkers=2",
23
19
  "format": "prettier --write {src,tests}/**/*.ts integration/*.ts",
24
20
  "format:check": "prettier --list-different {src,tests}/**/*.ts",