From 19bb09b4b4ad9b102e64ea3c017aaeb3811561f5 Mon Sep 17 00:00:00 2001 From: Timo Stamm Date: Thu, 14 Mar 2024 10:28:29 +0100 Subject: [PATCH] Update to google protobuf v26.0 (#747) --- .../failing_tests_without_bigint.txt | 18 ++--- .../google/protobuf/compiler/plugin_pb.d.ts | 20 ++++++ .../js/google/protobuf/compiler/plugin_pb.js | 2 + .../gen/js/google/protobuf/descriptor_pb.d.ts | 67 ++++++++--------- .../gen/js/google/protobuf/descriptor_pb.js | 5 +- .../js/google/protobuf/map_unittest_pb.d.ts | 24 +++++++ .../gen/js/google/protobuf/map_unittest_pb.js | 10 +++ .../ts/google/protobuf/compiler/plugin_pb.ts | 22 ++++++ .../gen/ts/google/protobuf/descriptor_pb.ts | 72 ++++++++++--------- .../gen/ts/google/protobuf/map_unittest_pb.ts | 37 ++++++++++ .../src/google/protobuf/compiler/plugin_pb.ts | 22 ++++++ .../src/google/protobuf/descriptor_pb.ts | 72 ++++++++++--------- packages/protobuf/src/private/feature-set.ts | 2 +- packages/upstream-protobuf/index.mjs | 2 + packages/upstream-protobuf/version.txt | 2 +- 15 files changed, 261 insertions(+), 116 deletions(-) diff --git a/packages/protobuf-conformance/failing_tests_without_bigint.txt b/packages/protobuf-conformance/failing_tests_without_bigint.txt index 102ca4e40..92d064173 100644 --- a/packages/protobuf-conformance/failing_tests_without_bigint.txt +++ b/packages/protobuf-conformance/failing_tests_without_bigint.txt @@ -3,24 +3,24 @@ # That means number values in JSON will be unsafe as well. If you plan to use # protobuf-es on runtimes without BigInt support, make sure that the JSON data # you consume does contains 64-bit values as strings instead of numbers. -# ERROR, test=Required.Proto3.JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput: Failed to parse input or produce output. request=json_payload: "{\"optionalInt64\": 9223372036854774784}" requested_output_format: PROTOBUF message_type: "protobuf_test_messages.proto3.TestAllTypesProto3" test_category: JSON_TEST, response=parse_error: "Error: cannot decode field protobuf_test_messages.proto3.TestAllTypesProto3.optional_int64 from JSON: 9223372036854775000: not a safe integer: 9223372036854775000" -# ERROR, test=Required.Proto3.JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput: Failed to parse input or produce output. request=json_payload: "{\"optionalInt64\": 9223372036854774784}" requested_output_format: JSON message_type: "protobuf_test_messages.proto3.TestAllTypesProto3" test_category: JSON_TEST, response=parse_error: "Error: cannot decode field protobuf_test_messages.proto3.TestAllTypesProto3.optional_int64 from JSON: 9223372036854775000: not a safe integer: 9223372036854775000" -# ERROR, test=Required.Proto3.JsonInput.Int64FieldMinValueNotQuoted.ProtobufOutput: Failed to parse input or produce output. request=json_payload: "{\"optionalInt64\": -9223372036854775808}" requested_output_format: PROTOBUF message_type: "protobuf_test_messages.proto3.TestAllTypesProto3" test_category: JSON_TEST, response=parse_error: "Error: cannot decode field protobuf_test_messages.proto3.TestAllTypesProto3.optional_int64 from JSON: -9223372036854776000: not a safe integer: -9223372036854776000" -# ERROR, test=Required.Proto3.JsonInput.Int64FieldMinValueNotQuoted.JsonOutput: Failed to parse input or produce output. request=json_payload: "{\"optionalInt64\": -9223372036854775808}" requested_output_format: JSON message_type: "protobuf_test_messages.proto3.TestAllTypesProto3" test_category: JSON_TEST, response=parse_error: "Error: cannot decode field protobuf_test_messages.proto3.TestAllTypesProto3.optional_int64 from JSON: -9223372036854776000: not a safe integer: -9223372036854776000" -# ERROR, test=Required.Proto3.JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput: Failed to parse input or produce output. request=json_payload: "{\"optionalUint64\": 18446744073709549568}" requested_output_format: PROTOBUF message_type: "protobuf_test_messages.proto3.TestAllTypesProto3" test_category: JSON_TEST, response=parse_error: "Error: cannot decode field protobuf_test_messages.proto3.TestAllTypesProto3.optional_uint64 from JSON: 18446744073709550000: not a safe integer: 18446744073709550000" -# ERROR, test=Required.Proto3.JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput: Failed to parse input or produce output. request=json_payload: "{\"optionalUint64\": 18446744073709549568}" requested_output_format: JSON message_type: "protobuf_test_messages.proto3.TestAllTypesProto3" test_category: JSON_TEST, response=parse_error: "Error: cannot decode field protobuf_test_messages.proto3.TestAllTypesProto3.optional_uint64 from JSON: 18446744073709550000: not a safe integer: 18446744073709550000" Required.Proto3.JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput Required.Proto3.JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput Required.Proto3.JsonInput.Int64FieldMinValueNotQuoted.ProtobufOutput Required.Proto3.JsonInput.Int64FieldMinValueNotQuoted.JsonOutput Required.Proto3.JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput Required.Proto3.JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput +Required.Proto2.JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput +Required.Proto2.JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput +Required.Proto2.JsonInput.Int64FieldMinValueNotQuoted.JsonOutput +Required.Proto2.JsonInput.Int64FieldMinValueNotQuoted.ProtobufOutput +Required.Proto2.JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput +Required.Proto2.JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput # Without BigInt support, our implementation does not validate that 64-bit # values are within bounds. -# ERROR, test=Required.Proto3.JsonInput.Int64FieldTooLarge: Should have failed to parse, but didn't. request=json_payload: "{\"optionalInt64\": \"9223372036854775808\"}" requested_output_format: JSON message_type: "protobuf_test_messages.proto3.TestAllTypesProto3" test_category: JSON_TEST, response=json_payload: "{\"optionalInt64\":\"9223372036854775808\"}" -# ERROR, test=Required.Proto3.JsonInput.Int64FieldTooSmall: Should have failed to parse, but didn't. request=json_payload: "{\"optionalInt64\": \"-9223372036854775809\"}" requested_output_format: JSON message_type: "protobuf_test_messages.proto3.TestAllTypesProto3" test_category: JSON_TEST, response=json_payload: "{\"optionalInt64\":\"-9223372036854775809\"}" -# ERROR, test=Required.Proto3.JsonInput.Uint64FieldTooLarge: Should have failed to parse, but didn't. request=json_payload: "{\"optionalUint64\": \"18446744073709551616\"}" requested_output_format: JSON message_type: "protobuf_test_messages.proto3.TestAllTypesProto3" test_category: JSON_TEST, response=json_payload: "{\"optionalUint64\":\"18446744073709551616\"}" Required.Proto3.JsonInput.Int64FieldTooLarge Required.Proto3.JsonInput.Int64FieldTooSmall Required.Proto3.JsonInput.Uint64FieldTooLarge +Required.Proto2.JsonInput.Int64FieldTooLarge +Required.Proto2.JsonInput.Int64FieldTooSmall +Required.Proto2.JsonInput.Uint64FieldTooLarge diff --git a/packages/protobuf-test/src/gen/js/google/protobuf/compiler/plugin_pb.d.ts b/packages/protobuf-test/src/gen/js/google/protobuf/compiler/plugin_pb.d.ts index 3dd7b4d99..364cbaee1 100644 --- a/packages/protobuf-test/src/gen/js/google/protobuf/compiler/plugin_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/google/protobuf/compiler/plugin_pb.d.ts @@ -183,6 +183,26 @@ export declare class CodeGeneratorResponse extends Message [ { no: 1, name: "error", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, { no: 2, name: "supported_features", kind: "scalar", T: 4 /* ScalarType.UINT64 */, opt: true }, + { no: 3, name: "minimum_edition", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, + { no: 4, name: "maximum_edition", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, { no: 15, name: "file", kind: "message", T: CodeGeneratorResponse_File, repeated: true }, ], ); diff --git a/packages/protobuf-test/src/gen/js/google/protobuf/descriptor_pb.d.ts b/packages/protobuf-test/src/gen/js/google/protobuf/descriptor_pb.d.ts index 151332951..e3455eb7b 100644 --- a/packages/protobuf-test/src/gen/js/google/protobuf/descriptor_pb.d.ts +++ b/packages/protobuf-test/src/gen/js/google/protobuf/descriptor_pb.d.ts @@ -64,6 +64,11 @@ export declare enum Edition { */ EDITION_2023 = 1000, + /** + * @generated from enum value: EDITION_2024 = 1001; + */ + EDITION_2024 = 1001, + /** * Placeholder editions for testing feature resolution. These should not be * used or relyed on outside of tests. @@ -91,6 +96,15 @@ export declare enum Edition { * @generated from enum value: EDITION_99999_TEST_ONLY = 99999; */ EDITION_99999_TEST_ONLY = 99999, + + /** + * Placeholder for specifying unbounded edition support. This should only + * ever be used by plugins that can expect to never require any changes to + * support a new edition. + * + * @generated from enum value: EDITION_MAX = 2147483647; + */ + EDITION_MAX = 2147483647, } /** @@ -595,12 +609,12 @@ export declare class FieldDescriptorProto extends Message * If true, this is a proto3 "optional". When a proto3 field is optional, it * tracks presence regardless of field type. * - * When proto3_optional is true, this field must be belong to a oneof to - * signal to old proto3 clients that presence is tracked for this field. This - * oneof is known as a "synthetic" oneof, and this field must be its sole - * member (each proto3 optional field gets its own synthetic oneof). Synthetic - * oneofs exist in the descriptor only, and do not generate any API. Synthetic - * oneofs must be ordered after all "real" oneofs. + * When proto3_optional is true, this field must belong to a oneof to signal + * to old proto3 clients that presence is tracked for this field. This oneof + * is known as a "synthetic" oneof, and this field must be its sole member + * (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs + * exist in the descriptor only, and do not generate any API. Synthetic oneofs + * must be ordered after all "real" oneofs. * * For message fields, proto3_optional doesn't create any semantic change, * since non-repeated message fields always track presence. However it still @@ -1130,11 +1144,6 @@ export declare class FileOptions extends Message { */ pyGenericServices?: boolean; - /** - * @generated from field: optional bool php_generic_services = 42 [default = false]; - */ - phpGenericServices?: boolean; - /** * Is this file deprecated? * Depending on the target platform, this can emit Deprecated annotations @@ -1321,10 +1330,6 @@ export declare class MessageOptions extends Message { deprecated?: boolean; /** - * NOTE: Do not set the option in .proto files. Always use the maps syntax - * instead. The option should only be implicitly set by the proto compiler - * parser. - * * Whether the message is an automatically generated map entry type for the * maps field. * @@ -1343,6 +1348,10 @@ export declare class MessageOptions extends Message { * The reflection APIs in such implementations still need to work as * if the field is a repeated message field. * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + * * @generated from field: optional bool map_entry = 7; */ mapEntry?: boolean; @@ -1457,19 +1466,11 @@ export declare class FieldOptions extends Message { * call from multiple threads concurrently, while non-const methods continue * to require exclusive access. * - * Note that implementations may choose not to check required fields within - * a lazy sub-message. That is, calling IsInitialized() on the outer message - * may return true even if the inner message has missing required fields. - * This is necessary because otherwise the inner message would have to be - * parsed in order to perform the check, defeating the purpose of lazy - * parsing. An implementation which chooses not to check required fields - * must be consistent about it. That is, for any particular sub-message, the - * implementation must either *always* check its required fields, or *never* - * check its required fields, regardless of whether or not the message has - * been parsed. - * - * As of May 2022, lazy verifies the contents of the byte stream during - * parsing. An invalid byte stream will cause the overall parsing to fail. + * Note that lazy message fields are still eagerly verified to check + * ill-formed wireformat or missing required fields. Calling IsInitialized() + * on the outer message would fail if the inner message has missing required + * fields. Failed verification would result in parsing failure (except when + * uninitialized messages are acceptable). * * @generated from field: optional bool lazy = 5 [default = false]; */ @@ -2221,14 +2222,14 @@ export declare enum FeatureSet_Utf8Validation { UTF8_VALIDATION_UNKNOWN = 0, /** - * @generated from enum value: NONE = 1; + * @generated from enum value: VERIFY = 2; */ - NONE = 1, + VERIFY = 2, /** - * @generated from enum value: VERIFY = 2; + * @generated from enum value: NONE = 3; */ - VERIFY = 2, + NONE = 3, } /** @@ -2430,7 +2431,7 @@ export declare class SourceCodeInfo_Location extends Message | undefined, b: TestRecursiveMapMessage | PlainMessage | undefined): boolean; } +/** + * @generated from message protobuf_unittest.TestI32StrMap + */ +export declare class TestI32StrMap extends Message { + /** + * @generated from field: map m_32_str = 1; + */ + m32Str: { [key: number]: string }; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "protobuf_unittest.TestI32StrMap"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): TestI32StrMap; + + static fromJson(jsonValue: JsonValue, options?: Partial): TestI32StrMap; + + static fromJsonString(jsonString: string, options?: Partial): TestI32StrMap; + + static equals(a: TestI32StrMap | PlainMessage | undefined, b: TestI32StrMap | PlainMessage | undefined): boolean; +} + diff --git a/packages/protobuf-test/src/gen/js/google/protobuf/map_unittest_pb.js b/packages/protobuf-test/src/gen/js/google/protobuf/map_unittest_pb.js index 42db53713..36ab2f747 100644 --- a/packages/protobuf-test/src/gen/js/google/protobuf/map_unittest_pb.js +++ b/packages/protobuf-test/src/gen/js/google/protobuf/map_unittest_pb.js @@ -181,3 +181,13 @@ export const TestRecursiveMapMessage = /*@__PURE__*/ proto3.makeMessageType( ], ); +/** + * @generated from message protobuf_unittest.TestI32StrMap + */ +export const TestI32StrMap = /*@__PURE__*/ proto3.makeMessageType( + "protobuf_unittest.TestI32StrMap", + () => [ + { no: 1, name: "m_32_str", kind: "map", K: 5 /* ScalarType.INT32 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, + ], +); + diff --git a/packages/protobuf-test/src/gen/ts/google/protobuf/compiler/plugin_pb.ts b/packages/protobuf-test/src/gen/ts/google/protobuf/compiler/plugin_pb.ts index d79c42f80..8d3dfd1bc 100644 --- a/packages/protobuf-test/src/gen/ts/google/protobuf/compiler/plugin_pb.ts +++ b/packages/protobuf-test/src/gen/ts/google/protobuf/compiler/plugin_pb.ts @@ -216,6 +216,26 @@ export class CodeGeneratorResponse extends Message { */ supportedFeatures?: bigint; + /** + * The minimum edition this plugin supports. This will be treated as an + * Edition enum, but we want to allow unknown values. It should be specified + * according the edition enum value, *not* the edition number. Only takes + * effect for plugins that have FEATURE_SUPPORTS_EDITIONS set. + * + * @generated from field: optional int32 minimum_edition = 3; + */ + minimumEdition?: number; + + /** + * The maximum edition this plugin supports. This will be treated as an + * Edition enum, but we want to allow unknown values. It should be specified + * according the edition enum value, *not* the edition number. Only takes + * effect for plugins that have FEATURE_SUPPORTS_EDITIONS set. + * + * @generated from field: optional int32 maximum_edition = 4; + */ + maximumEdition?: number; + /** * @generated from field: repeated google.protobuf.compiler.CodeGeneratorResponse.File file = 15; */ @@ -231,6 +251,8 @@ export class CodeGeneratorResponse extends Message { static readonly fields: FieldList = proto2.util.newFieldList(() => [ { no: 1, name: "error", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, { no: 2, name: "supported_features", kind: "scalar", T: 4 /* ScalarType.UINT64 */, opt: true }, + { no: 3, name: "minimum_edition", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, + { no: 4, name: "maximum_edition", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, { no: 15, name: "file", kind: "message", T: CodeGeneratorResponse_File, repeated: true }, ]); diff --git a/packages/protobuf-test/src/gen/ts/google/protobuf/descriptor_pb.ts b/packages/protobuf-test/src/gen/ts/google/protobuf/descriptor_pb.ts index d25653480..0563912e1 100644 --- a/packages/protobuf-test/src/gen/ts/google/protobuf/descriptor_pb.ts +++ b/packages/protobuf-test/src/gen/ts/google/protobuf/descriptor_pb.ts @@ -64,6 +64,11 @@ export enum Edition { */ EDITION_2023 = 1000, + /** + * @generated from enum value: EDITION_2024 = 1001; + */ + EDITION_2024 = 1001, + /** * Placeholder editions for testing feature resolution. These should not be * used or relyed on outside of tests. @@ -91,6 +96,15 @@ export enum Edition { * @generated from enum value: EDITION_99999_TEST_ONLY = 99999; */ EDITION_99999_TEST_ONLY = 99999, + + /** + * Placeholder for specifying unbounded edition support. This should only + * ever be used by plugins that can expect to never require any changes to + * support a new edition. + * + * @generated from enum value: EDITION_MAX = 2147483647; + */ + EDITION_MAX = 2147483647, } // Retrieve enum metadata with: proto2.getEnumType(Edition) proto2.util.setEnumType(Edition, "google.protobuf.Edition", [ @@ -98,11 +112,13 @@ proto2.util.setEnumType(Edition, "google.protobuf.Edition", [ { no: 998, name: "EDITION_PROTO2" }, { no: 999, name: "EDITION_PROTO3" }, { no: 1000, name: "EDITION_2023" }, + { no: 1001, name: "EDITION_2024" }, { no: 1, name: "EDITION_1_TEST_ONLY" }, { no: 2, name: "EDITION_2_TEST_ONLY" }, { no: 99997, name: "EDITION_99997_TEST_ONLY" }, { no: 99998, name: "EDITION_99998_TEST_ONLY" }, { no: 99999, name: "EDITION_99999_TEST_ONLY" }, + { no: 2147483647, name: "EDITION_MAX" }, ]); /** @@ -734,12 +750,12 @@ export class FieldDescriptorProto extends Message { * If true, this is a proto3 "optional". When a proto3 field is optional, it * tracks presence regardless of field type. * - * When proto3_optional is true, this field must be belong to a oneof to - * signal to old proto3 clients that presence is tracked for this field. This - * oneof is known as a "synthetic" oneof, and this field must be its sole - * member (each proto3 optional field gets its own synthetic oneof). Synthetic - * oneofs exist in the descriptor only, and do not generate any API. Synthetic - * oneofs must be ordered after all "real" oneofs. + * When proto3_optional is true, this field must belong to a oneof to signal + * to old proto3 clients that presence is tracked for this field. This oneof + * is known as a "synthetic" oneof, and this field must be its sole member + * (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs + * exist in the descriptor only, and do not generate any API. Synthetic oneofs + * must be ordered after all "real" oneofs. * * For message fields, proto3_optional doesn't create any semantic change, * since non-repeated message fields always track presence. However it still @@ -1412,11 +1428,6 @@ export class FileOptions extends Message { */ pyGenericServices?: boolean; - /** - * @generated from field: optional bool php_generic_services = 42 [default = false]; - */ - phpGenericServices?: boolean; - /** * Is this file deprecated? * Depending on the target platform, this can emit Deprecated annotations @@ -1528,7 +1539,6 @@ export class FileOptions extends Message { { no: 16, name: "cc_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false }, { no: 17, name: "java_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false }, { no: 18, name: "py_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false }, - { no: 42, name: "php_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false }, { no: 23, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false }, { no: 31, name: "cc_enable_arenas", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: true }, { no: 36, name: "objc_class_prefix", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, @@ -1643,10 +1653,6 @@ export class MessageOptions extends Message { deprecated?: boolean; /** - * NOTE: Do not set the option in .proto files. Always use the maps syntax - * instead. The option should only be implicitly set by the proto compiler - * parser. - * * Whether the message is an automatically generated map entry type for the * maps field. * @@ -1665,6 +1671,10 @@ export class MessageOptions extends Message { * The reflection APIs in such implementations still need to work as * if the field is a repeated message field. * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + * * @generated from field: optional bool map_entry = 7; */ mapEntry?: boolean; @@ -1798,19 +1808,11 @@ export class FieldOptions extends Message { * call from multiple threads concurrently, while non-const methods continue * to require exclusive access. * - * Note that implementations may choose not to check required fields within - * a lazy sub-message. That is, calling IsInitialized() on the outer message - * may return true even if the inner message has missing required fields. - * This is necessary because otherwise the inner message would have to be - * parsed in order to perform the check, defeating the purpose of lazy - * parsing. An implementation which chooses not to check required fields - * must be consistent about it. That is, for any particular sub-message, the - * implementation must either *always* check its required fields, or *never* - * check its required fields, regardless of whether or not the message has - * been parsed. - * - * As of May 2022, lazy verifies the contents of the byte stream during - * parsing. An invalid byte stream will cause the overall parsing to fail. + * Note that lazy message fields are still eagerly verified to check + * ill-formed wireformat or missing required fields. Calling IsInitialized() + * on the outer message would fail if the inner message has missing required + * fields. Failed verification would result in parsing failure (except when + * uninitialized messages are acceptable). * * @generated from field: optional bool lazy = 5 [default = false]; */ @@ -2786,20 +2788,20 @@ export enum FeatureSet_Utf8Validation { UTF8_VALIDATION_UNKNOWN = 0, /** - * @generated from enum value: NONE = 1; + * @generated from enum value: VERIFY = 2; */ - NONE = 1, + VERIFY = 2, /** - * @generated from enum value: VERIFY = 2; + * @generated from enum value: NONE = 3; */ - VERIFY = 2, + NONE = 3, } // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_Utf8Validation) proto2.util.setEnumType(FeatureSet_Utf8Validation, "google.protobuf.FeatureSet.Utf8Validation", [ { no: 0, name: "UTF8_VALIDATION_UNKNOWN" }, - { no: 1, name: "NONE" }, { no: 2, name: "VERIFY" }, + { no: 3, name: "NONE" }, ]); /** @@ -3055,7 +3057,7 @@ export class SourceCodeInfo_Location extends Message { * location. * * Each element is a field number or an index. They form a path from - * the root FileDescriptorProto to the place where the definition occurs. + * the root FileDescriptorProto to the place where the definition appears. * For example, this path: * [ 4, 3, 2, 7, 1 ] * refers to: diff --git a/packages/protobuf-test/src/gen/ts/google/protobuf/map_unittest_pb.ts b/packages/protobuf-test/src/gen/ts/google/protobuf/map_unittest_pb.ts index 2e9f69b50..67df69ae7 100644 --- a/packages/protobuf-test/src/gen/ts/google/protobuf/map_unittest_pb.ts +++ b/packages/protobuf-test/src/gen/ts/google/protobuf/map_unittest_pb.ts @@ -618,3 +618,40 @@ export class TestRecursiveMapMessage extends Message { } } +/** + * @generated from message protobuf_unittest.TestI32StrMap + */ +export class TestI32StrMap extends Message { + /** + * @generated from field: map m_32_str = 1; + */ + m32Str: { [key: number]: string } = {}; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "protobuf_unittest.TestI32StrMap"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "m_32_str", kind: "map", K: 5 /* ScalarType.INT32 */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TestI32StrMap { + return new TestI32StrMap().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TestI32StrMap { + return new TestI32StrMap().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TestI32StrMap { + return new TestI32StrMap().fromJsonString(jsonString, options); + } + + static equals(a: TestI32StrMap | PlainMessage | undefined, b: TestI32StrMap | PlainMessage | undefined): boolean { + return proto3.util.equals(TestI32StrMap, a, b); + } +} + diff --git a/packages/protobuf/src/google/protobuf/compiler/plugin_pb.ts b/packages/protobuf/src/google/protobuf/compiler/plugin_pb.ts index e4653b929..f1630c359 100644 --- a/packages/protobuf/src/google/protobuf/compiler/plugin_pb.ts +++ b/packages/protobuf/src/google/protobuf/compiler/plugin_pb.ts @@ -220,6 +220,26 @@ export class CodeGeneratorResponse extends Message { */ supportedFeatures?: bigint; + /** + * The minimum edition this plugin supports. This will be treated as an + * Edition enum, but we want to allow unknown values. It should be specified + * according the edition enum value, *not* the edition number. Only takes + * effect for plugins that have FEATURE_SUPPORTS_EDITIONS set. + * + * @generated from field: optional int32 minimum_edition = 3; + */ + minimumEdition?: number; + + /** + * The maximum edition this plugin supports. This will be treated as an + * Edition enum, but we want to allow unknown values. It should be specified + * according the edition enum value, *not* the edition number. Only takes + * effect for plugins that have FEATURE_SUPPORTS_EDITIONS set. + * + * @generated from field: optional int32 maximum_edition = 4; + */ + maximumEdition?: number; + /** * @generated from field: repeated google.protobuf.compiler.CodeGeneratorResponse.File file = 15; */ @@ -235,6 +255,8 @@ export class CodeGeneratorResponse extends Message { static readonly fields: FieldList = proto2.util.newFieldList(() => [ { no: 1, name: "error", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, { no: 2, name: "supported_features", kind: "scalar", T: 4 /* ScalarType.UINT64 */, opt: true }, + { no: 3, name: "minimum_edition", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, + { no: 4, name: "maximum_edition", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, { no: 15, name: "file", kind: "message", T: CodeGeneratorResponse_File, repeated: true }, ]); diff --git a/packages/protobuf/src/google/protobuf/descriptor_pb.ts b/packages/protobuf/src/google/protobuf/descriptor_pb.ts index d92fbee67..ea09ee2d6 100644 --- a/packages/protobuf/src/google/protobuf/descriptor_pb.ts +++ b/packages/protobuf/src/google/protobuf/descriptor_pb.ts @@ -68,6 +68,11 @@ export enum Edition { */ EDITION_2023 = 1000, + /** + * @generated from enum value: EDITION_2024 = 1001; + */ + EDITION_2024 = 1001, + /** * Placeholder editions for testing feature resolution. These should not be * used or relyed on outside of tests. @@ -95,6 +100,15 @@ export enum Edition { * @generated from enum value: EDITION_99999_TEST_ONLY = 99999; */ EDITION_99999_TEST_ONLY = 99999, + + /** + * Placeholder for specifying unbounded edition support. This should only + * ever be used by plugins that can expect to never require any changes to + * support a new edition. + * + * @generated from enum value: EDITION_MAX = 2147483647; + */ + EDITION_MAX = 2147483647, } // Retrieve enum metadata with: proto2.getEnumType(Edition) proto2.util.setEnumType(Edition, "google.protobuf.Edition", [ @@ -102,11 +116,13 @@ proto2.util.setEnumType(Edition, "google.protobuf.Edition", [ { no: 998, name: "EDITION_PROTO2" }, { no: 999, name: "EDITION_PROTO3" }, { no: 1000, name: "EDITION_2023" }, + { no: 1001, name: "EDITION_2024" }, { no: 1, name: "EDITION_1_TEST_ONLY" }, { no: 2, name: "EDITION_2_TEST_ONLY" }, { no: 99997, name: "EDITION_99997_TEST_ONLY" }, { no: 99998, name: "EDITION_99998_TEST_ONLY" }, { no: 99999, name: "EDITION_99999_TEST_ONLY" }, + { no: 2147483647, name: "EDITION_MAX" }, ]); /** @@ -738,12 +754,12 @@ export class FieldDescriptorProto extends Message { * If true, this is a proto3 "optional". When a proto3 field is optional, it * tracks presence regardless of field type. * - * When proto3_optional is true, this field must be belong to a oneof to - * signal to old proto3 clients that presence is tracked for this field. This - * oneof is known as a "synthetic" oneof, and this field must be its sole - * member (each proto3 optional field gets its own synthetic oneof). Synthetic - * oneofs exist in the descriptor only, and do not generate any API. Synthetic - * oneofs must be ordered after all "real" oneofs. + * When proto3_optional is true, this field must belong to a oneof to signal + * to old proto3 clients that presence is tracked for this field. This oneof + * is known as a "synthetic" oneof, and this field must be its sole member + * (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs + * exist in the descriptor only, and do not generate any API. Synthetic oneofs + * must be ordered after all "real" oneofs. * * For message fields, proto3_optional doesn't create any semantic change, * since non-repeated message fields always track presence. However it still @@ -1416,11 +1432,6 @@ export class FileOptions extends Message { */ pyGenericServices?: boolean; - /** - * @generated from field: optional bool php_generic_services = 42 [default = false]; - */ - phpGenericServices?: boolean; - /** * Is this file deprecated? * Depending on the target platform, this can emit Deprecated annotations @@ -1532,7 +1543,6 @@ export class FileOptions extends Message { { no: 16, name: "cc_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false }, { no: 17, name: "java_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false }, { no: 18, name: "py_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false }, - { no: 42, name: "php_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false }, { no: 23, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false }, { no: 31, name: "cc_enable_arenas", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: true }, { no: 36, name: "objc_class_prefix", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, @@ -1647,10 +1657,6 @@ export class MessageOptions extends Message { deprecated?: boolean; /** - * NOTE: Do not set the option in .proto files. Always use the maps syntax - * instead. The option should only be implicitly set by the proto compiler - * parser. - * * Whether the message is an automatically generated map entry type for the * maps field. * @@ -1669,6 +1675,10 @@ export class MessageOptions extends Message { * The reflection APIs in such implementations still need to work as * if the field is a repeated message field. * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + * * @generated from field: optional bool map_entry = 7; */ mapEntry?: boolean; @@ -1802,19 +1812,11 @@ export class FieldOptions extends Message { * call from multiple threads concurrently, while non-const methods continue * to require exclusive access. * - * Note that implementations may choose not to check required fields within - * a lazy sub-message. That is, calling IsInitialized() on the outer message - * may return true even if the inner message has missing required fields. - * This is necessary because otherwise the inner message would have to be - * parsed in order to perform the check, defeating the purpose of lazy - * parsing. An implementation which chooses not to check required fields - * must be consistent about it. That is, for any particular sub-message, the - * implementation must either *always* check its required fields, or *never* - * check its required fields, regardless of whether or not the message has - * been parsed. - * - * As of May 2022, lazy verifies the contents of the byte stream during - * parsing. An invalid byte stream will cause the overall parsing to fail. + * Note that lazy message fields are still eagerly verified to check + * ill-formed wireformat or missing required fields. Calling IsInitialized() + * on the outer message would fail if the inner message has missing required + * fields. Failed verification would result in parsing failure (except when + * uninitialized messages are acceptable). * * @generated from field: optional bool lazy = 5 [default = false]; */ @@ -2790,20 +2792,20 @@ export enum FeatureSet_Utf8Validation { UTF8_VALIDATION_UNKNOWN = 0, /** - * @generated from enum value: NONE = 1; + * @generated from enum value: VERIFY = 2; */ - NONE = 1, + VERIFY = 2, /** - * @generated from enum value: VERIFY = 2; + * @generated from enum value: NONE = 3; */ - VERIFY = 2, + NONE = 3, } // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_Utf8Validation) proto2.util.setEnumType(FeatureSet_Utf8Validation, "google.protobuf.FeatureSet.Utf8Validation", [ { no: 0, name: "UTF8_VALIDATION_UNKNOWN" }, - { no: 1, name: "NONE" }, { no: 2, name: "VERIFY" }, + { no: 3, name: "NONE" }, ]); /** @@ -3059,7 +3061,7 @@ export class SourceCodeInfo_Location extends Message { * location. * * Each element is a field number or an index. They form a path from - * the root FileDescriptorProto to the place where the definition occurs. + * the root FileDescriptorProto to the place where the definition appears. * For example, this path: * [ 4, 3, 2, 7, 1 ] * refers to: diff --git a/packages/protobuf/src/private/feature-set.ts b/packages/protobuf/src/private/feature-set.ts index 5e8ecef8c..8ad867f6a 100644 --- a/packages/protobuf/src/private/feature-set.ts +++ b/packages/protobuf/src/private/feature-set.ts @@ -31,7 +31,7 @@ function getFeatureSetDefaults( ): FeatureSetDefaults { return FeatureSetDefaults.fromBinary( protoBase64.dec( - /*upstream-inject-feature-defaults-start*/ "ChESDAgBEAIYAiABKAEwAhjmBwoREgwIAhABGAEgAigBMAEY5wcKERIMCAEQARgBIAIoATABGOgHIOYHKOgH" /*upstream-inject-feature-defaults-end*/, + /*upstream-inject-feature-defaults-start*/ "ChESDAgBEAIYAiADKAEwAhjmBwoREgwIAhABGAEgAigBMAEY5wcKERIMCAEQARgBIAIoATABGOgHIOYHKOgH" /*upstream-inject-feature-defaults-end*/, ), options, ); diff --git a/packages/upstream-protobuf/index.mjs b/packages/upstream-protobuf/index.mjs index 36ba78559..cfb5558da 100644 --- a/packages/upstream-protobuf/index.mjs +++ b/packages/upstream-protobuf/index.mjs @@ -60,6 +60,7 @@ export class UpstreamProtobuf { // - google/protobuf/unittest_arena.proto // - google/protobuf/unittest_drop_unknown_fields.proto // - google/protobuf/unittest_lazy_dependencies_custom_option.proto + // - google/protobuf/unittest_legacy_features.proto /** * Relevant proto files for testing in upstream protobuf. * @@ -79,6 +80,7 @@ export class UpstreamProtobuf { "!src/google/protobuf/unittest_no_field_presence.proto", "!src/google/protobuf/unittest_preserve_unknown_enum.proto", "!src/google/protobuf/unittest_preserve_unknown_enum2.proto", + "!src/google/protobuf/unittest_legacy_features.proto", ]; /** diff --git a/packages/upstream-protobuf/version.txt b/packages/upstream-protobuf/version.txt index a5615e130..facd73a33 100644 --- a/packages/upstream-protobuf/version.txt +++ b/packages/upstream-protobuf/version.txt @@ -1 +1 @@ -25.2 +26.0