ts-proto 2.8.2 → 2.9.0

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.
@@ -1,7 +1,7 @@
1
1
  import { TypeMap } from "./types";
2
2
  import { Utils } from "./main";
3
3
  import { Options } from "./options";
4
- import { FileDescriptorProto } from "ts-proto-descriptors";
4
+ import { Edition, FileDescriptorProto } from "ts-proto-descriptors";
5
5
  /** Provides a parameter object for passing around the various context/config data. */
6
6
  export interface BaseContext {
7
7
  options: Options;
@@ -13,7 +13,7 @@ export interface Context extends BaseContext {
13
13
  }
14
14
  export interface FileContext {
15
15
  isProto3Syntax: boolean;
16
+ isEdition: boolean;
17
+ edition: Edition | undefined;
16
18
  }
17
- export declare function createFileContext(file: FileDescriptorProto): {
18
- isProto3Syntax: boolean;
19
- };
19
+ export declare function createFileContext(file: FileDescriptorProto): FileContext;
@@ -1,6 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createFileContext = createFileContext;
4
+ const ts_proto_descriptors_1 = require("ts-proto-descriptors");
4
5
  function createFileContext(file) {
5
- return { isProto3Syntax: file.syntax === "proto3" };
6
+ const edition = file.edition !== ts_proto_descriptors_1.Edition.EDITION_UNKNOWN ? file.edition : undefined;
7
+ const isEdition = edition !== undefined;
8
+ const isProto3Syntax = file.syntax === "proto3" || (file.syntax !== "proto2" && isProto3Edition(edition));
9
+ return {
10
+ isProto3Syntax,
11
+ isEdition,
12
+ edition,
13
+ };
14
+ }
15
+ function isProto3Edition(edition) {
16
+ if (edition === undefined) {
17
+ return false;
18
+ }
19
+ return edition === ts_proto_descriptors_1.Edition.EDITION_PROTO3 || edition === ts_proto_descriptors_1.Edition.EDITION_2023 || edition === ts_proto_descriptors_1.Edition.EDITION_2024;
6
20
  }
@@ -201,7 +201,7 @@ function generateWrapShallow(ctx, fullProtoTypeName, fieldNames) {
201
201
  chunks.push((0, ts_poet_1.code) `wrap(value: any): ${(0, utils_1.wrapTypeName)(ctx.options, "Value")} {
202
202
  const result = createBase${(0, utils_1.wrapTypeName)(ctx.options, "Value")}()${maybeAsAny(ctx.options)};
203
203
  if (value === null) {
204
- result.kind = {$case: '${fieldNames.nullValue}', value };
204
+ result.kind = {$case: '${fieldNames.nullValue}', value: ${(0, utils_1.wrapTypeName)(ctx.options, "NullValue")}.NULL_VALUE};
205
205
  } else if (typeof value === 'boolean') {
206
206
  result.kind = {$case: '${fieldNames.boolValue}', value };
207
207
  } else if (typeof value === 'number') {
@@ -310,7 +310,7 @@ function generateUnwrapShallow(ctx, fullProtoTypeName, fieldNames) {
310
310
  }
311
311
  else if (ctx.options.oneof === options_1.OneofOption.UNIONS_VALUE) {
312
312
  chunks.push((0, ts_poet_1.code) `unwrap(message: ${(0, utils_1.wrapTypeName)(ctx.options, "Value")}): string | number | boolean | Object | null | Array<any> | undefined {
313
- return message.kind?.value;
313
+ return (message.kind?.$case === '${fieldNames.nullValue}') ? null : message.kind?.value;
314
314
  }`);
315
315
  }
316
316
  else {
@@ -62,7 +62,9 @@ async function main() {
62
62
  }
63
63
  const response = ts_proto_descriptors_1.CodeGeneratorResponse.fromPartial({
64
64
  file: files,
65
- supportedFeatures: ts_proto_descriptors_1.CodeGeneratorResponse_Feature.FEATURE_PROTO3_OPTIONAL,
65
+ supportedFeatures: ts_proto_descriptors_1.CodeGeneratorResponse_Feature.FEATURE_PROTO3_OPTIONAL | ts_proto_descriptors_1.CodeGeneratorResponse_Feature.FEATURE_SUPPORTS_EDITIONS,
66
+ minimumEdition: ts_proto_descriptors_1.Edition.EDITION_PROTO2,
67
+ maximumEdition: ts_proto_descriptors_1.Edition.EDITION_2024,
66
68
  });
67
69
  const buffer = ts_proto_descriptors_1.CodeGeneratorResponse.encode(response).finish();
68
70
  const write = (0, util_1.promisify)(process.stdout.write).bind(process.stdout);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "2.8.2",
3
+ "version": "2.9.0",
4
4
  "description": "",
5
5
  "main": "build/src/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",
@@ -36,12 +36,12 @@
36
36
  "@nestjs/core": "^9.4.3",
37
37
  "@nestjs/microservices": "^9.4.3",
38
38
  "@semantic-release/changelog": "^6.0.3",
39
- "@semantic-release/commit-analyzer": "^13.0.0",
40
- "@semantic-release/exec": "^6.0.3",
39
+ "@semantic-release/commit-analyzer": "^13.0.1",
40
+ "@semantic-release/exec": "^7.1.0",
41
41
  "@semantic-release/git": "^10.0.1",
42
- "@semantic-release/github": "^10.1.6",
43
- "@semantic-release/npm": "^12.0.1",
44
- "@semantic-release/release-notes-generator": "^14.0.1",
42
+ "@semantic-release/github": "^12.0.2",
43
+ "@semantic-release/npm": "^13.1.3",
44
+ "@semantic-release/release-notes-generator": "^14.1.0",
45
45
  "@tsconfig/strictest": "^2.0.1",
46
46
  "@types/jest": "^29.5.3",
47
47
  "@types/node": "^16.18.38",
@@ -56,11 +56,12 @@
56
56
  "nice-grpc": "^2.1.4",
57
57
  "object-hash": "^3.0.0",
58
58
  "prettier": "^3.5.3",
59
+ "prettier-legacy": "npm:prettier@2.8.8",
59
60
  "protobufjs": "^7.2.4",
60
61
  "protobufjs-cli": "^1.1.1",
61
62
  "reflect-metadata": "^0.1.13",
62
63
  "rxjs": "^7.8.1",
63
- "semantic-release": "^24.0.0",
64
+ "semantic-release": "^25.0.2",
64
65
  "temporal-polyfill": "^0.3.0",
65
66
  "temporal-spec": "^0.3.0",
66
67
  "ts-jest": "^29.3.4",
@@ -72,7 +73,7 @@
72
73
  "@bufbuild/protobuf": "^2.0.0",
73
74
  "case-anything": "^2.1.13",
74
75
  "ts-poet": "^6.12.0",
75
- "ts-proto-descriptors": "2.0.0"
76
+ "ts-proto-descriptors": "2.1.0"
76
77
  },
77
78
  "packageManager": "yarn@4.4.0"
78
79
  }