ts-proto 1.130.0 → 1.131.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.131.1](https://github.com/stephenh/ts-proto/compare/v1.131.0...v1.131.1) (2022-11-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 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))
7
+
8
+ # [1.131.0](https://github.com/stephenh/ts-proto/compare/v1.130.0...v1.131.0) (2022-10-25)
9
+
10
+
11
+ ### Features
12
+
13
+ * option useSnakeTypeName ([#694](https://github.com/stephenh/ts-proto/issues/694)) ([ad73ff9](https://github.com/stephenh/ts-proto/commit/ad73ff9341d0d593156d10b5d96c4a47afdc802d))
14
+
1
15
  # [1.130.0](https://github.com/stephenh/ts-proto/compare/v1.129.0...v1.130.0) (2022-10-22)
2
16
 
3
17
 
package/README.markdown CHANGED
@@ -464,6 +464,24 @@ Generated code will be placed in the Gradle build directory.
464
464
 
465
465
  - With `--ts_proto_opt=useReadonlyTypes=true`, the generated types will be declared as immutable using typescript's `readonly` modifer.
466
466
 
467
+ - With `--ts_proto_opt=useSnakeTypeName=false` will remove snake casing from types.
468
+
469
+ Example Protobuf
470
+ ```protobuf
471
+ message Box {
472
+ message Element {
473
+ message Image {
474
+ enum Alignment {
475
+ LEFT = 1;
476
+ CENTER = 2;
477
+ RIGHT = 3;
478
+ }
479
+ }
480
+ }
481
+ }
482
+ ```
483
+ by default this is enabled which would generate a type of `Box_Element_Image_Alignment`. By disabling this option the type that is generated would be `BoxElementImageAlignment`.
484
+
467
485
  ### NestJS Support
468
486
 
469
487
  We have a great way of working together with [nestjs](https://docs.nestjs.com/microservices/grpc). `ts-proto` generates `interfaces` and `decorators` for you controller, client. For more information see the [nestjs readme](NESTJS.markdown).
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/options.js CHANGED
@@ -74,6 +74,7 @@ function defaultOptions() {
74
74
  initializeFieldsAsUndefined: true,
75
75
  useMapType: false,
76
76
  useReadonlyTypes: false,
77
+ useSnakeTypeName: true,
77
78
  M: {},
78
79
  };
79
80
  }
package/build/visit.js CHANGED
@@ -23,7 +23,8 @@ function visit(proto, sourceInfo, messageFn, options, enumFn = () => { }, tsPref
23
23
  const tsFullName = tsPrefix + (0, case_1.maybeSnakeToCamel)(messageName(message), options);
24
24
  const nestedSourceInfo = sourceInfo.open(childType, index);
25
25
  messageFn(tsFullName, message, nestedSourceInfo, protoFullName);
26
- visit(message, nestedSourceInfo, messageFn, options, enumFn, tsFullName + "_", protoFullName + ".");
26
+ const delim = options.useSnakeTypeName ? "_" : "";
27
+ visit(message, nestedSourceInfo, messageFn, options, enumFn, tsFullName + delim, protoFullName + ".");
27
28
  });
28
29
  }
29
30
  exports.visit = visit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.130.0",
3
+ "version": "1.131.1",
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",