@bufbuild/protobuf 1.3.3 → 1.4.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.
Files changed (60) hide show
  1. package/dist/cjs/codegen-info.d.ts +1 -1
  2. package/dist/cjs/codegen-info.js +1 -0
  3. package/dist/cjs/create-descriptor-set.js +10 -4
  4. package/dist/cjs/create-registry-from-desc.js +7 -7
  5. package/dist/cjs/descriptor-set.d.ts +21 -1
  6. package/dist/cjs/field.d.ts +52 -1
  7. package/dist/cjs/field.js +29 -1
  8. package/dist/cjs/google/protobuf/any_pb.d.ts +2 -1
  9. package/dist/cjs/google/protobuf/any_pb.js +2 -1
  10. package/dist/cjs/google/protobuf/compiler/plugin_pb.d.ts +18 -1
  11. package/dist/cjs/google/protobuf/compiler/plugin_pb.js +19 -0
  12. package/dist/cjs/google/protobuf/descriptor_pb.d.ts +250 -16
  13. package/dist/cjs/google/protobuf/descriptor_pb.js +241 -7
  14. package/dist/cjs/google/protobuf/duration_pb.js +1 -1
  15. package/dist/cjs/google/protobuf/struct_pb.js +1 -1
  16. package/dist/cjs/google/protobuf/type_pb.js +1 -1
  17. package/dist/cjs/index.d.ts +1 -1
  18. package/dist/cjs/index.js +2 -1
  19. package/dist/cjs/json-format.d.ts +3 -1
  20. package/dist/cjs/private/binary-format-common.d.ts +4 -4
  21. package/dist/cjs/private/binary-format-common.js +18 -6
  22. package/dist/cjs/private/json-format-common.d.ts +1 -1
  23. package/dist/cjs/private/json-format-common.js +11 -7
  24. package/dist/cjs/private/scalars.d.ts +2 -2
  25. package/dist/cjs/private/scalars.js +6 -5
  26. package/dist/cjs/proto2.js +6 -2
  27. package/dist/cjs/proto3.js +6 -3
  28. package/dist/cjs/to-plain-message.d.ts +5 -2
  29. package/dist/cjs/to-plain-message.js +7 -1
  30. package/dist/esm/codegen-info.d.ts +1 -1
  31. package/dist/esm/codegen-info.js +1 -0
  32. package/dist/esm/create-descriptor-set.js +13 -7
  33. package/dist/esm/create-registry-from-desc.js +7 -7
  34. package/dist/esm/descriptor-set.d.ts +21 -1
  35. package/dist/esm/field.d.ts +52 -1
  36. package/dist/esm/field.js +28 -0
  37. package/dist/esm/google/protobuf/any_pb.d.ts +2 -1
  38. package/dist/esm/google/protobuf/any_pb.js +2 -1
  39. package/dist/esm/google/protobuf/compiler/plugin_pb.d.ts +18 -1
  40. package/dist/esm/google/protobuf/compiler/plugin_pb.js +19 -0
  41. package/dist/esm/google/protobuf/descriptor_pb.d.ts +250 -16
  42. package/dist/esm/google/protobuf/descriptor_pb.js +238 -6
  43. package/dist/esm/google/protobuf/duration_pb.js +1 -1
  44. package/dist/esm/google/protobuf/struct_pb.js +1 -1
  45. package/dist/esm/google/protobuf/type_pb.js +1 -1
  46. package/dist/esm/index.d.ts +1 -1
  47. package/dist/esm/index.js +1 -1
  48. package/dist/esm/json-format.d.ts +3 -1
  49. package/dist/esm/json-format.js +1 -1
  50. package/dist/esm/private/binary-format-common.d.ts +4 -4
  51. package/dist/esm/private/binary-format-common.js +17 -6
  52. package/dist/esm/private/json-format-common.d.ts +1 -1
  53. package/dist/esm/private/json-format-common.js +12 -8
  54. package/dist/esm/private/scalars.d.ts +2 -2
  55. package/dist/esm/private/scalars.js +7 -6
  56. package/dist/esm/proto2.js +6 -2
  57. package/dist/esm/proto3.js +7 -4
  58. package/dist/esm/to-plain-message.d.ts +5 -2
  59. package/dist/esm/to-plain-message.js +7 -1
  60. package/package.json +8 -1
@@ -13,7 +13,7 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.GeneratedCodeInfo_Annotation_Semantic = exports.GeneratedCodeInfo_Annotation = exports.GeneratedCodeInfo = exports.SourceCodeInfo_Location = exports.SourceCodeInfo = exports.UninterpretedOption_NamePart = exports.UninterpretedOption = exports.MethodOptions_IdempotencyLevel = exports.MethodOptions = exports.ServiceOptions = exports.EnumValueOptions = exports.EnumOptions = exports.OneofOptions = exports.FieldOptions_OptionTargetType = exports.FieldOptions_OptionRetention = exports.FieldOptions_JSType = exports.FieldOptions_CType = exports.FieldOptions = exports.MessageOptions = exports.FileOptions_OptimizeMode = exports.FileOptions = exports.MethodDescriptorProto = exports.ServiceDescriptorProto = exports.EnumValueDescriptorProto = exports.EnumDescriptorProto_EnumReservedRange = exports.EnumDescriptorProto = exports.OneofDescriptorProto = exports.FieldDescriptorProto_Label = exports.FieldDescriptorProto_Type = exports.FieldDescriptorProto = exports.ExtensionRangeOptions_Declaration = exports.ExtensionRangeOptions_VerificationState = exports.ExtensionRangeOptions = exports.DescriptorProto_ReservedRange = exports.DescriptorProto_ExtensionRange = exports.DescriptorProto = exports.FileDescriptorProto = exports.FileDescriptorSet = void 0;
16
+ exports.GeneratedCodeInfo_Annotation_Semantic = exports.GeneratedCodeInfo_Annotation = exports.GeneratedCodeInfo = exports.SourceCodeInfo_Location = exports.SourceCodeInfo = exports.FeatureSet_JsonFormat = exports.FeatureSet_MessageEncoding = exports.FeatureSet_StringFieldValidation = exports.FeatureSet_RepeatedFieldEncoding = exports.FeatureSet_EnumType = exports.FeatureSet_FieldPresence = exports.FeatureSet = exports.UninterpretedOption_NamePart = exports.UninterpretedOption = exports.MethodOptions_IdempotencyLevel = exports.MethodOptions = exports.ServiceOptions = exports.EnumValueOptions = exports.EnumOptions = exports.OneofOptions = exports.FieldOptions_EditionDefault = exports.FieldOptions_OptionTargetType = exports.FieldOptions_OptionRetention = exports.FieldOptions_JSType = exports.FieldOptions_CType = exports.FieldOptions = exports.MessageOptions = exports.FileOptions_OptimizeMode = exports.FileOptions = exports.MethodDescriptorProto = exports.ServiceDescriptorProto = exports.EnumValueDescriptorProto = exports.EnumDescriptorProto_EnumReservedRange = exports.EnumDescriptorProto = exports.OneofDescriptorProto = exports.FieldDescriptorProto_Label = exports.FieldDescriptorProto_Type = exports.FieldDescriptorProto = exports.ExtensionRangeOptions_Declaration = exports.ExtensionRangeOptions_VerificationState = exports.ExtensionRangeOptions = exports.DescriptorProto_ReservedRange = exports.DescriptorProto_ExtensionRange = exports.DescriptorProto = exports.FileDescriptorProto = exports.FileDescriptorSet = void 0;
17
17
  const message_js_1 = require("../../message.js");
18
18
  const proto2_js_1 = require("../../proto2.js");
19
19
  /**
@@ -275,10 +275,9 @@ class ExtensionRangeOptions extends message_js_1.Message {
275
275
  */
276
276
  this.uninterpretedOption = [];
277
277
  /**
278
- * go/protobuf-stripping-extension-declarations
279
- * Like Metadata, but we use a repeated field to hold all extension
280
- * declarations. This should avoid the size increases of transforming a large
281
- * extension range into small ranges in generated binaries.
278
+ * For external users: DO NOT USE. We are in the process of open sourcing
279
+ * extension declaration and executing internal cleanups before it can be
280
+ * used externally.
282
281
  *
283
282
  * @generated from field: repeated google.protobuf.ExtensionRangeOptions.Declaration declaration = 2;
284
283
  */
@@ -304,6 +303,7 @@ ExtensionRangeOptions.typeName = "google.protobuf.ExtensionRangeOptions";
304
303
  ExtensionRangeOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
305
304
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
306
305
  { no: 2, name: "declaration", kind: "message", T: ExtensionRangeOptions_Declaration, repeated: true },
306
+ { no: 50, name: "features", kind: "message", T: FeatureSet, opt: true },
307
307
  { no: 3, name: "verification", kind: "enum", T: proto2_js_1.proto2.getEnumType(ExtensionRangeOptions_VerificationState), opt: true, default: ExtensionRangeOptions_VerificationState.UNVERIFIED },
308
308
  ]);
309
309
  /**
@@ -357,7 +357,6 @@ ExtensionRangeOptions_Declaration.fields = proto2_js_1.proto2.util.newFieldList(
357
357
  { no: 1, name: "number", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
358
358
  { no: 2, name: "full_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
359
359
  { no: 3, name: "type", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
360
- { no: 4, name: "is_repeated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
361
360
  { no: 5, name: "reserved", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
362
361
  { no: 6, name: "repeated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
363
362
  ]);
@@ -816,6 +815,7 @@ FileOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
816
815
  { no: 41, name: "php_namespace", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
817
816
  { no: 44, name: "php_metadata_namespace", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
818
817
  { no: 45, name: "ruby_package", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
818
+ { no: 50, name: "features", kind: "message", T: FeatureSet, opt: true },
819
819
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
820
820
  ]);
821
821
  /**
@@ -888,6 +888,7 @@ MessageOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
888
888
  { no: 3, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
889
889
  { no: 7, name: "map_entry", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
890
890
  { no: 11, name: "deprecated_legacy_json_field_conflicts", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
891
+ { no: 12, name: "features", kind: "message", T: FeatureSet, opt: true },
891
892
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
892
893
  ]);
893
894
  /**
@@ -900,6 +901,10 @@ class FieldOptions extends message_js_1.Message {
900
901
  * @generated from field: repeated google.protobuf.FieldOptions.OptionTargetType targets = 19;
901
902
  */
902
903
  this.targets = [];
904
+ /**
905
+ * @generated from field: repeated google.protobuf.FieldOptions.EditionDefault edition_defaults = 20;
906
+ */
907
+ this.editionDefaults = [];
903
908
  /**
904
909
  * The parser stores options it doesn't recognize here. See above.
905
910
  *
@@ -934,8 +939,9 @@ FieldOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
934
939
  { no: 10, name: "weak", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
935
940
  { no: 16, name: "debug_redact", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
936
941
  { no: 17, name: "retention", kind: "enum", T: proto2_js_1.proto2.getEnumType(FieldOptions_OptionRetention), opt: true },
937
- { no: 18, name: "target", kind: "enum", T: proto2_js_1.proto2.getEnumType(FieldOptions_OptionTargetType), opt: true },
938
942
  { no: 19, name: "targets", kind: "enum", T: proto2_js_1.proto2.getEnumType(FieldOptions_OptionTargetType), repeated: true },
943
+ { no: 20, name: "edition_defaults", kind: "message", T: FieldOptions_EditionDefault, repeated: true },
944
+ { no: 21, name: "features", kind: "message", T: FeatureSet, opt: true },
939
945
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
940
946
  ]);
941
947
  /**
@@ -1093,6 +1099,34 @@ proto2_js_1.proto2.util.setEnumType(FieldOptions_OptionTargetType, "google.proto
1093
1099
  { no: 8, name: "TARGET_TYPE_SERVICE" },
1094
1100
  { no: 9, name: "TARGET_TYPE_METHOD" },
1095
1101
  ]);
1102
+ /**
1103
+ * @generated from message google.protobuf.FieldOptions.EditionDefault
1104
+ */
1105
+ class FieldOptions_EditionDefault extends message_js_1.Message {
1106
+ constructor(data) {
1107
+ super();
1108
+ proto2_js_1.proto2.util.initPartial(data, this);
1109
+ }
1110
+ static fromBinary(bytes, options) {
1111
+ return new FieldOptions_EditionDefault().fromBinary(bytes, options);
1112
+ }
1113
+ static fromJson(jsonValue, options) {
1114
+ return new FieldOptions_EditionDefault().fromJson(jsonValue, options);
1115
+ }
1116
+ static fromJsonString(jsonString, options) {
1117
+ return new FieldOptions_EditionDefault().fromJsonString(jsonString, options);
1118
+ }
1119
+ static equals(a, b) {
1120
+ return proto2_js_1.proto2.util.equals(FieldOptions_EditionDefault, a, b);
1121
+ }
1122
+ }
1123
+ exports.FieldOptions_EditionDefault = FieldOptions_EditionDefault;
1124
+ FieldOptions_EditionDefault.runtime = proto2_js_1.proto2;
1125
+ FieldOptions_EditionDefault.typeName = "google.protobuf.FieldOptions.EditionDefault";
1126
+ FieldOptions_EditionDefault.fields = proto2_js_1.proto2.util.newFieldList(() => [
1127
+ { no: 1, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
1128
+ { no: 2, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
1129
+ ]);
1096
1130
  /**
1097
1131
  * @generated from message google.protobuf.OneofOptions
1098
1132
  */
@@ -1124,6 +1158,7 @@ exports.OneofOptions = OneofOptions;
1124
1158
  OneofOptions.runtime = proto2_js_1.proto2;
1125
1159
  OneofOptions.typeName = "google.protobuf.OneofOptions";
1126
1160
  OneofOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
1161
+ { no: 1, name: "features", kind: "message", T: FeatureSet, opt: true },
1127
1162
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
1128
1163
  ]);
1129
1164
  /**
@@ -1160,6 +1195,7 @@ EnumOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
1160
1195
  { no: 2, name: "allow_alias", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
1161
1196
  { no: 3, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
1162
1197
  { no: 6, name: "deprecated_legacy_json_field_conflicts", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
1198
+ { no: 7, name: "features", kind: "message", T: FeatureSet, opt: true },
1163
1199
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
1164
1200
  ]);
1165
1201
  /**
@@ -1194,6 +1230,8 @@ EnumValueOptions.runtime = proto2_js_1.proto2;
1194
1230
  EnumValueOptions.typeName = "google.protobuf.EnumValueOptions";
1195
1231
  EnumValueOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
1196
1232
  { no: 1, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
1233
+ { no: 2, name: "features", kind: "message", T: FeatureSet, opt: true },
1234
+ { no: 3, name: "debug_redact", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
1197
1235
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
1198
1236
  ]);
1199
1237
  /**
@@ -1227,6 +1265,7 @@ exports.ServiceOptions = ServiceOptions;
1227
1265
  ServiceOptions.runtime = proto2_js_1.proto2;
1228
1266
  ServiceOptions.typeName = "google.protobuf.ServiceOptions";
1229
1267
  ServiceOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
1268
+ { no: 34, name: "features", kind: "message", T: FeatureSet, opt: true },
1230
1269
  { no: 33, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
1231
1270
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
1232
1271
  ]);
@@ -1263,6 +1302,7 @@ MethodOptions.typeName = "google.protobuf.MethodOptions";
1263
1302
  MethodOptions.fields = proto2_js_1.proto2.util.newFieldList(() => [
1264
1303
  { no: 33, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
1265
1304
  { no: 34, name: "idempotency_level", kind: "enum", T: proto2_js_1.proto2.getEnumType(MethodOptions_IdempotencyLevel), opt: true, default: MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN },
1305
+ { no: 35, name: "features", kind: "message", T: FeatureSet, opt: true },
1266
1306
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
1267
1307
  ]);
1268
1308
  /**
@@ -1375,6 +1415,200 @@ UninterpretedOption_NamePart.fields = proto2_js_1.proto2.util.newFieldList(() =>
1375
1415
  { no: 1, name: "name_part", kind: "scalar", T: 9 /* ScalarType.STRING */ },
1376
1416
  { no: 2, name: "is_extension", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
1377
1417
  ]);
1418
+ /**
1419
+ * TODO(b/274655146) Enums in C++ gencode (and potentially other languages) are
1420
+ * not well scoped. This means that each of the feature enums below can clash
1421
+ * with each other. The short names we've chosen maximize call-site
1422
+ * readability, but leave us very open to this scenario. A future feature will
1423
+ * be designed and implemented to handle this, hopefully before we ever hit a
1424
+ * conflict here.
1425
+ *
1426
+ * @generated from message google.protobuf.FeatureSet
1427
+ */
1428
+ class FeatureSet extends message_js_1.Message {
1429
+ constructor(data) {
1430
+ super();
1431
+ proto2_js_1.proto2.util.initPartial(data, this);
1432
+ }
1433
+ static fromBinary(bytes, options) {
1434
+ return new FeatureSet().fromBinary(bytes, options);
1435
+ }
1436
+ static fromJson(jsonValue, options) {
1437
+ return new FeatureSet().fromJson(jsonValue, options);
1438
+ }
1439
+ static fromJsonString(jsonString, options) {
1440
+ return new FeatureSet().fromJsonString(jsonString, options);
1441
+ }
1442
+ static equals(a, b) {
1443
+ return proto2_js_1.proto2.util.equals(FeatureSet, a, b);
1444
+ }
1445
+ }
1446
+ exports.FeatureSet = FeatureSet;
1447
+ FeatureSet.runtime = proto2_js_1.proto2;
1448
+ FeatureSet.typeName = "google.protobuf.FeatureSet";
1449
+ FeatureSet.fields = proto2_js_1.proto2.util.newFieldList(() => [
1450
+ { no: 1, name: "field_presence", kind: "enum", T: proto2_js_1.proto2.getEnumType(FeatureSet_FieldPresence), opt: true },
1451
+ { no: 2, name: "enum_type", kind: "enum", T: proto2_js_1.proto2.getEnumType(FeatureSet_EnumType), opt: true },
1452
+ { no: 3, name: "repeated_field_encoding", kind: "enum", T: proto2_js_1.proto2.getEnumType(FeatureSet_RepeatedFieldEncoding), opt: true },
1453
+ { no: 4, name: "string_field_validation", kind: "enum", T: proto2_js_1.proto2.getEnumType(FeatureSet_StringFieldValidation), opt: true },
1454
+ { no: 5, name: "message_encoding", kind: "enum", T: proto2_js_1.proto2.getEnumType(FeatureSet_MessageEncoding), opt: true },
1455
+ { no: 6, name: "json_format", kind: "enum", T: proto2_js_1.proto2.getEnumType(FeatureSet_JsonFormat), opt: true },
1456
+ { no: 999, name: "raw_features", kind: "message", T: FeatureSet, opt: true },
1457
+ ]);
1458
+ /**
1459
+ * @generated from enum google.protobuf.FeatureSet.FieldPresence
1460
+ */
1461
+ var FeatureSet_FieldPresence;
1462
+ (function (FeatureSet_FieldPresence) {
1463
+ /**
1464
+ * @generated from enum value: FIELD_PRESENCE_UNKNOWN = 0;
1465
+ */
1466
+ FeatureSet_FieldPresence[FeatureSet_FieldPresence["FIELD_PRESENCE_UNKNOWN"] = 0] = "FIELD_PRESENCE_UNKNOWN";
1467
+ /**
1468
+ * @generated from enum value: EXPLICIT = 1;
1469
+ */
1470
+ FeatureSet_FieldPresence[FeatureSet_FieldPresence["EXPLICIT"] = 1] = "EXPLICIT";
1471
+ /**
1472
+ * @generated from enum value: IMPLICIT = 2;
1473
+ */
1474
+ FeatureSet_FieldPresence[FeatureSet_FieldPresence["IMPLICIT"] = 2] = "IMPLICIT";
1475
+ /**
1476
+ * @generated from enum value: LEGACY_REQUIRED = 3;
1477
+ */
1478
+ FeatureSet_FieldPresence[FeatureSet_FieldPresence["LEGACY_REQUIRED"] = 3] = "LEGACY_REQUIRED";
1479
+ })(FeatureSet_FieldPresence || (exports.FeatureSet_FieldPresence = FeatureSet_FieldPresence = {}));
1480
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_FieldPresence)
1481
+ proto2_js_1.proto2.util.setEnumType(FeatureSet_FieldPresence, "google.protobuf.FeatureSet.FieldPresence", [
1482
+ { no: 0, name: "FIELD_PRESENCE_UNKNOWN" },
1483
+ { no: 1, name: "EXPLICIT" },
1484
+ { no: 2, name: "IMPLICIT" },
1485
+ { no: 3, name: "LEGACY_REQUIRED" },
1486
+ ]);
1487
+ /**
1488
+ * @generated from enum google.protobuf.FeatureSet.EnumType
1489
+ */
1490
+ var FeatureSet_EnumType;
1491
+ (function (FeatureSet_EnumType) {
1492
+ /**
1493
+ * @generated from enum value: ENUM_TYPE_UNKNOWN = 0;
1494
+ */
1495
+ FeatureSet_EnumType[FeatureSet_EnumType["ENUM_TYPE_UNKNOWN"] = 0] = "ENUM_TYPE_UNKNOWN";
1496
+ /**
1497
+ * @generated from enum value: OPEN = 1;
1498
+ */
1499
+ FeatureSet_EnumType[FeatureSet_EnumType["OPEN"] = 1] = "OPEN";
1500
+ /**
1501
+ * @generated from enum value: CLOSED = 2;
1502
+ */
1503
+ FeatureSet_EnumType[FeatureSet_EnumType["CLOSED"] = 2] = "CLOSED";
1504
+ })(FeatureSet_EnumType || (exports.FeatureSet_EnumType = FeatureSet_EnumType = {}));
1505
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_EnumType)
1506
+ proto2_js_1.proto2.util.setEnumType(FeatureSet_EnumType, "google.protobuf.FeatureSet.EnumType", [
1507
+ { no: 0, name: "ENUM_TYPE_UNKNOWN" },
1508
+ { no: 1, name: "OPEN" },
1509
+ { no: 2, name: "CLOSED" },
1510
+ ]);
1511
+ /**
1512
+ * @generated from enum google.protobuf.FeatureSet.RepeatedFieldEncoding
1513
+ */
1514
+ var FeatureSet_RepeatedFieldEncoding;
1515
+ (function (FeatureSet_RepeatedFieldEncoding) {
1516
+ /**
1517
+ * @generated from enum value: REPEATED_FIELD_ENCODING_UNKNOWN = 0;
1518
+ */
1519
+ FeatureSet_RepeatedFieldEncoding[FeatureSet_RepeatedFieldEncoding["REPEATED_FIELD_ENCODING_UNKNOWN"] = 0] = "REPEATED_FIELD_ENCODING_UNKNOWN";
1520
+ /**
1521
+ * @generated from enum value: PACKED = 1;
1522
+ */
1523
+ FeatureSet_RepeatedFieldEncoding[FeatureSet_RepeatedFieldEncoding["PACKED"] = 1] = "PACKED";
1524
+ /**
1525
+ * @generated from enum value: EXPANDED = 2;
1526
+ */
1527
+ FeatureSet_RepeatedFieldEncoding[FeatureSet_RepeatedFieldEncoding["EXPANDED"] = 2] = "EXPANDED";
1528
+ })(FeatureSet_RepeatedFieldEncoding || (exports.FeatureSet_RepeatedFieldEncoding = FeatureSet_RepeatedFieldEncoding = {}));
1529
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_RepeatedFieldEncoding)
1530
+ proto2_js_1.proto2.util.setEnumType(FeatureSet_RepeatedFieldEncoding, "google.protobuf.FeatureSet.RepeatedFieldEncoding", [
1531
+ { no: 0, name: "REPEATED_FIELD_ENCODING_UNKNOWN" },
1532
+ { no: 1, name: "PACKED" },
1533
+ { no: 2, name: "EXPANDED" },
1534
+ ]);
1535
+ /**
1536
+ * @generated from enum google.protobuf.FeatureSet.StringFieldValidation
1537
+ */
1538
+ var FeatureSet_StringFieldValidation;
1539
+ (function (FeatureSet_StringFieldValidation) {
1540
+ /**
1541
+ * @generated from enum value: STRING_FIELD_VALIDATION_UNKNOWN = 0;
1542
+ */
1543
+ FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["STRING_FIELD_VALIDATION_UNKNOWN"] = 0] = "STRING_FIELD_VALIDATION_UNKNOWN";
1544
+ /**
1545
+ * @generated from enum value: MANDATORY = 1;
1546
+ */
1547
+ FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["MANDATORY"] = 1] = "MANDATORY";
1548
+ /**
1549
+ * @generated from enum value: HINT = 2;
1550
+ */
1551
+ FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["HINT"] = 2] = "HINT";
1552
+ /**
1553
+ * @generated from enum value: NONE = 3;
1554
+ */
1555
+ FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["NONE"] = 3] = "NONE";
1556
+ })(FeatureSet_StringFieldValidation || (exports.FeatureSet_StringFieldValidation = FeatureSet_StringFieldValidation = {}));
1557
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_StringFieldValidation)
1558
+ proto2_js_1.proto2.util.setEnumType(FeatureSet_StringFieldValidation, "google.protobuf.FeatureSet.StringFieldValidation", [
1559
+ { no: 0, name: "STRING_FIELD_VALIDATION_UNKNOWN" },
1560
+ { no: 1, name: "MANDATORY" },
1561
+ { no: 2, name: "HINT" },
1562
+ { no: 3, name: "NONE" },
1563
+ ]);
1564
+ /**
1565
+ * @generated from enum google.protobuf.FeatureSet.MessageEncoding
1566
+ */
1567
+ var FeatureSet_MessageEncoding;
1568
+ (function (FeatureSet_MessageEncoding) {
1569
+ /**
1570
+ * @generated from enum value: MESSAGE_ENCODING_UNKNOWN = 0;
1571
+ */
1572
+ FeatureSet_MessageEncoding[FeatureSet_MessageEncoding["MESSAGE_ENCODING_UNKNOWN"] = 0] = "MESSAGE_ENCODING_UNKNOWN";
1573
+ /**
1574
+ * @generated from enum value: LENGTH_PREFIXED = 1;
1575
+ */
1576
+ FeatureSet_MessageEncoding[FeatureSet_MessageEncoding["LENGTH_PREFIXED"] = 1] = "LENGTH_PREFIXED";
1577
+ /**
1578
+ * @generated from enum value: DELIMITED = 2;
1579
+ */
1580
+ FeatureSet_MessageEncoding[FeatureSet_MessageEncoding["DELIMITED"] = 2] = "DELIMITED";
1581
+ })(FeatureSet_MessageEncoding || (exports.FeatureSet_MessageEncoding = FeatureSet_MessageEncoding = {}));
1582
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_MessageEncoding)
1583
+ proto2_js_1.proto2.util.setEnumType(FeatureSet_MessageEncoding, "google.protobuf.FeatureSet.MessageEncoding", [
1584
+ { no: 0, name: "MESSAGE_ENCODING_UNKNOWN" },
1585
+ { no: 1, name: "LENGTH_PREFIXED" },
1586
+ { no: 2, name: "DELIMITED" },
1587
+ ]);
1588
+ /**
1589
+ * @generated from enum google.protobuf.FeatureSet.JsonFormat
1590
+ */
1591
+ var FeatureSet_JsonFormat;
1592
+ (function (FeatureSet_JsonFormat) {
1593
+ /**
1594
+ * @generated from enum value: JSON_FORMAT_UNKNOWN = 0;
1595
+ */
1596
+ FeatureSet_JsonFormat[FeatureSet_JsonFormat["JSON_FORMAT_UNKNOWN"] = 0] = "JSON_FORMAT_UNKNOWN";
1597
+ /**
1598
+ * @generated from enum value: ALLOW = 1;
1599
+ */
1600
+ FeatureSet_JsonFormat[FeatureSet_JsonFormat["ALLOW"] = 1] = "ALLOW";
1601
+ /**
1602
+ * @generated from enum value: LEGACY_BEST_EFFORT = 2;
1603
+ */
1604
+ FeatureSet_JsonFormat[FeatureSet_JsonFormat["LEGACY_BEST_EFFORT"] = 2] = "LEGACY_BEST_EFFORT";
1605
+ })(FeatureSet_JsonFormat || (exports.FeatureSet_JsonFormat = FeatureSet_JsonFormat = {}));
1606
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_JsonFormat)
1607
+ proto2_js_1.proto2.util.setEnumType(FeatureSet_JsonFormat, "google.protobuf.FeatureSet.JsonFormat", [
1608
+ { no: 0, name: "JSON_FORMAT_UNKNOWN" },
1609
+ { no: 1, name: "ALLOW" },
1610
+ { no: 2, name: "LEGACY_BEST_EFFORT" },
1611
+ ]);
1378
1612
  /**
1379
1613
  * Encapsulates information about the original source file from which a
1380
1614
  * FileDescriptorProto was generated.
@@ -141,7 +141,7 @@ class Duration extends message_js_1.Message {
141
141
  nanosStr = nanosStr.substring(0, 6);
142
142
  }
143
143
  text += "." + nanosStr;
144
- if (this.nanos < 0 && this.seconds === proto_int64_js_1.protoInt64.zero) {
144
+ if (this.nanos < 0 && Number(this.seconds) == 0) {
145
145
  text = "-" + text;
146
146
  }
147
147
  }
@@ -14,7 +14,7 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.ListValue = exports.Value = exports.Struct = exports.NullValue = void 0;
17
- // @generated by protoc-gen-es v1.3.3 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
17
+ // @generated by protoc-gen-es v1.4.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
18
18
  // @generated from file google/protobuf/struct.proto (package google.protobuf, syntax proto3)
19
19
  /* eslint-disable */
20
20
  const proto3_js_1 = require("../../proto3.js");
@@ -14,7 +14,7 @@
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.Option = exports.EnumValue = exports.Enum = exports.Field_Cardinality = exports.Field_Kind = exports.Field = exports.Type = exports.Syntax = void 0;
17
- // @generated by protoc-gen-es v1.3.3 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
17
+ // @generated by protoc-gen-es v1.4.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
18
18
  // @generated from file google/protobuf/type.proto (package google.protobuf, syntax proto3)
19
19
  /* eslint-disable */
20
20
  const proto3_js_1 = require("../../proto3.js");
@@ -9,7 +9,7 @@ export { Message } from "./message.js";
9
9
  export type { AnyMessage, PartialMessage, PlainMessage } from "./message.js";
10
10
  export type { FieldInfo } from "./field.js";
11
11
  export type { FieldList } from "./field-list.js";
12
- export { ScalarType } from "./field.js";
12
+ export { ScalarType, LongType } from "./field.js";
13
13
  export type { MessageType } from "./message-type.js";
14
14
  export type { EnumType, EnumValueInfo } from "./enum.js";
15
15
  export type { ServiceType, MethodInfo, MethodInfoUnary, MethodInfoServerStreaming, MethodInfoClientStreaming, MethodInfoBiDiStreaming, } from "./service-type.js";
package/dist/cjs/index.js CHANGED
@@ -27,7 +27,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
27
27
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.toPlainMessage = exports.createRegistryFromDescriptors = exports.createRegistry = exports.createDescriptorSet = exports.BinaryReader = exports.BinaryWriter = exports.WireType = exports.MethodIdempotency = exports.MethodKind = exports.ScalarType = exports.Message = exports.codegenInfo = exports.protoDelimited = exports.protoBase64 = exports.protoInt64 = exports.protoDouble = exports.proto2 = exports.proto3 = void 0;
30
+ exports.toPlainMessage = exports.createRegistryFromDescriptors = exports.createRegistry = exports.createDescriptorSet = exports.BinaryReader = exports.BinaryWriter = exports.WireType = exports.MethodIdempotency = exports.MethodKind = exports.LongType = exports.ScalarType = exports.Message = exports.codegenInfo = exports.protoDelimited = exports.protoBase64 = exports.protoInt64 = exports.protoDouble = exports.proto2 = exports.proto3 = void 0;
31
31
  var proto3_js_1 = require("./proto3.js");
32
32
  Object.defineProperty(exports, "proto3", { enumerable: true, get: function () { return proto3_js_1.proto3; } });
33
33
  var proto2_js_1 = require("./proto2.js");
@@ -46,6 +46,7 @@ var message_js_1 = require("./message.js");
46
46
  Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return message_js_1.Message; } });
47
47
  var field_js_1 = require("./field.js");
48
48
  Object.defineProperty(exports, "ScalarType", { enumerable: true, get: function () { return field_js_1.ScalarType; } });
49
+ Object.defineProperty(exports, "LongType", { enumerable: true, get: function () { return field_js_1.LongType; } });
49
50
  var service_type_js_1 = require("./service-type.js");
50
51
  Object.defineProperty(exports, "MethodKind", { enumerable: true, get: function () { return service_type_js_1.MethodKind; } });
51
52
  Object.defineProperty(exports, "MethodIdempotency", { enumerable: true, get: function () { return service_type_js_1.MethodIdempotency; } });
@@ -1,6 +1,7 @@
1
1
  import type { Message } from "./message.js";
2
2
  import type { MessageType } from "./message-type.js";
3
3
  import type { ScalarType } from "./field.js";
4
+ import { LongType } from "./field.js";
4
5
  import type { IMessageTypeRegistry } from "./type-registry.js";
5
6
  /**
6
7
  * JsonFormat is the contract for serializing messages to and from JSON.
@@ -26,10 +27,11 @@ export interface JsonFormat {
26
27
  writeMessage(message: Message, options: JsonWriteOptions): JsonValue;
27
28
  /**
28
29
  * Parse a single scalar value from JSON.
30
+ *
29
31
  * This method may throw an error, but it may have a blank error message.
30
32
  * Callers are expected to provide context.
31
33
  */
32
- readScalar(type: ScalarType, json: JsonValue): any;
34
+ readScalar(type: ScalarType, json: JsonValue, longType?: LongType): any;
33
35
  /**
34
36
  * Serialize a single scalar value to JSON.
35
37
  */
@@ -1,10 +1,10 @@
1
- import type { IBinaryWriter } from "../binary-encoding.js";
2
- import type { BinaryWriteOptions } from "../binary-format.js";
3
- import type { BinaryFormat } from "../binary-format.js";
4
- import { ScalarType } from "../field.js";
1
+ import type { IBinaryReader, IBinaryWriter } from "../binary-encoding.js";
2
+ import type { BinaryFormat, BinaryWriteOptions } from "../binary-format.js";
5
3
  import type { FieldInfo } from "../field.js";
4
+ import { ScalarType } from "../field.js";
6
5
  import type { MessageType } from "../message-type.js";
7
6
  export declare function makeBinaryFormatCommon(): Omit<BinaryFormat, "writeMessage">;
7
+ export declare function readScalarLTString(reader: IBinaryReader, type: ScalarType): any;
8
8
  export declare function writeMapEntry(writer: IBinaryWriter, options: BinaryWriteOptions, field: FieldInfo & {
9
9
  kind: "map";
10
10
  }, key: any, value: any): void;
@@ -13,7 +13,7 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.writePacked = exports.writeScalar = exports.writeMessageField = exports.writeMapEntry = exports.makeBinaryFormatCommon = void 0;
16
+ exports.writePacked = exports.writeScalar = exports.writeMessageField = exports.writeMapEntry = exports.readScalarLTString = exports.makeBinaryFormatCommon = void 0;
17
17
  const binary_encoding_js_1 = require("../binary-encoding.js");
18
18
  const message_js_1 = require("../message.js");
19
19
  const field_js_1 = require("../field.js");
@@ -90,6 +90,11 @@ function makeBinaryFormatCommon() {
90
90
  case "scalar":
91
91
  case "enum":
92
92
  const scalarType = field.kind == "enum" ? field_js_1.ScalarType.INT32 : field.T;
93
+ let read = readScalar;
94
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison -- acceptable since it's covered by tests
95
+ if (field.kind == "scalar" && field.L > 0) {
96
+ read = readScalarLTString;
97
+ }
93
98
  if (repeated) {
94
99
  let arr = target[localName]; // safe to assume presence of array, oneof cannot contain repeated values
95
100
  if (wireType == binary_encoding_js_1.WireType.LengthDelimited &&
@@ -97,15 +102,15 @@ function makeBinaryFormatCommon() {
97
102
  scalarType != field_js_1.ScalarType.BYTES) {
98
103
  let e = reader.uint32() + reader.pos;
99
104
  while (reader.pos < e) {
100
- arr.push(readScalar(reader, scalarType));
105
+ arr.push(read(reader, scalarType));
101
106
  }
102
107
  }
103
108
  else {
104
- arr.push(readScalar(reader, scalarType));
109
+ arr.push(read(reader, scalarType));
105
110
  }
106
111
  }
107
112
  else {
108
- target[localName] = readScalar(reader, scalarType);
113
+ target[localName] = read(reader, scalarType);
109
114
  }
110
115
  break;
111
116
  case "message":
@@ -172,7 +177,7 @@ function readMapEntry(field, reader, options) {
172
177
  }
173
178
  }
174
179
  if (key === undefined) {
175
- let keyRaw = (0, scalars_js_1.scalarDefaultValue)(field.K);
180
+ let keyRaw = (0, scalars_js_1.scalarDefaultValue)(field.K, field_js_1.LongType.BIGINT);
176
181
  key =
177
182
  field.K == field_js_1.ScalarType.BOOL
178
183
  ? keyRaw.toString()
@@ -184,7 +189,7 @@ function readMapEntry(field, reader, options) {
184
189
  if (val === undefined) {
185
190
  switch (field.V.kind) {
186
191
  case "scalar":
187
- val = (0, scalars_js_1.scalarDefaultValue)(field.V.T);
192
+ val = (0, scalars_js_1.scalarDefaultValue)(field.V.T, field_js_1.LongType.BIGINT);
188
193
  break;
189
194
  case "enum":
190
195
  val = 0;
@@ -196,6 +201,13 @@ function readMapEntry(field, reader, options) {
196
201
  }
197
202
  return [key, val];
198
203
  }
204
+ // Read a scalar value, but return 64 bit integral types (int64, uint64,
205
+ // sint64, fixed64, sfixed64) as string instead of bigint.
206
+ function readScalarLTString(reader, type) {
207
+ const v = readScalar(reader, type);
208
+ return typeof v == "bigint" ? v.toString() : v;
209
+ }
210
+ exports.readScalarLTString = readScalarLTString;
199
211
  // Does not use scalarTypeInfo() for better performance.
200
212
  function readScalar(reader, type) {
201
213
  switch (type) {
@@ -1,6 +1,6 @@
1
1
  import type { JsonFormat, JsonValue, JsonWriteOptions } from "../json-format.js";
2
- import { ScalarType } from "../field.js";
3
2
  import type { FieldInfo } from "../field.js";
3
+ import { ScalarType } from "../field.js";
4
4
  import type { EnumType } from "../enum.js";
5
5
  type JsonFormatWriteFieldFn = (field: FieldInfo, value: any, options: JsonWriteOptions) => JsonValue | undefined;
6
6
  export declare function makeJsonFormatCommon(makeWriteField: (writeEnumFn: typeof writeEnum, writeScalarFn: typeof writeScalar) => JsonFormatWriteFieldFn): JsonFormat;
@@ -96,7 +96,7 @@ function makeJsonFormatCommon(makeWriteField) {
96
96
  break;
97
97
  case "scalar":
98
98
  try {
99
- val = readScalar(field.T, jsonItem);
99
+ val = readScalar(field.T, jsonItem, field.L);
100
100
  }
101
101
  catch (e) {
102
102
  let m = `cannot decode field ${type.typeName}.${field.name} from JSON: ${this.debug(jsonItem)}`;
@@ -134,7 +134,7 @@ function makeJsonFormatCommon(makeWriteField) {
134
134
  break;
135
135
  case "scalar":
136
136
  try {
137
- val = readScalar(field.V.T, jsonMapValue);
137
+ val = readScalar(field.V.T, jsonMapValue, field_js_1.LongType.BIGINT);
138
138
  }
139
139
  catch (e) {
140
140
  let m = `cannot decode map value for field ${type.typeName}.${field.name} from JSON: ${this.debug(jsonValue)}`;
@@ -152,7 +152,7 @@ function makeJsonFormatCommon(makeWriteField) {
152
152
  : jsonMapKey == "false"
153
153
  ? false
154
154
  : jsonMapKey
155
- : jsonMapKey).toString()] = val;
155
+ : jsonMapKey, field_js_1.LongType.BIGINT).toString()] = val;
156
156
  }
157
157
  catch (e) {
158
158
  let m = `cannot decode map key for field ${type.typeName}.${field.name} from JSON: ${this.debug(jsonValue)}`;
@@ -192,7 +192,7 @@ function makeJsonFormatCommon(makeWriteField) {
192
192
  break;
193
193
  case "scalar":
194
194
  try {
195
- target[localName] = readScalar(field.T, jsonValue);
195
+ target[localName] = readScalar(field.T, jsonValue, field.L);
196
196
  }
197
197
  catch (e) {
198
198
  let m = `cannot decode field ${type.typeName}.${field.name} from JSON: ${this.debug(jsonValue)}`;
@@ -265,7 +265,7 @@ function debugJsonValue(json) {
265
265
  }
266
266
  // May throw an error. If the error message is non-blank, it should be shown.
267
267
  // It is up to the caller to provide context.
268
- function readScalar(type, json) {
268
+ function readScalar(type, json, longType) {
269
269
  // every valid case in the switch below returns, and every fall
270
270
  // through is regarded as a failure.
271
271
  switch (type) {
@@ -334,14 +334,18 @@ function readScalar(type, json) {
334
334
  return proto_int64_js_1.protoInt64.zero;
335
335
  if (typeof json != "number" && typeof json != "string")
336
336
  break;
337
- return proto_int64_js_1.protoInt64.parse(json);
337
+ const long = proto_int64_js_1.protoInt64.parse(json);
338
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
339
+ return longType ? long.toString() : long;
338
340
  case field_js_1.ScalarType.FIXED64:
339
341
  case field_js_1.ScalarType.UINT64:
340
342
  if (json === null)
341
343
  return proto_int64_js_1.protoInt64.zero;
342
344
  if (typeof json != "number" && typeof json != "string")
343
345
  break;
344
- return proto_int64_js_1.protoInt64.uParse(json);
346
+ const uLong = proto_int64_js_1.protoInt64.uParse(json);
347
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
348
+ return longType ? uLong.toString() : uLong;
345
349
  // bool:
346
350
  case field_js_1.ScalarType.BOOL:
347
351
  if (json === null)
@@ -1,4 +1,4 @@
1
- import { ScalarType } from "../field.js";
1
+ import { LongType, ScalarType } from "../field.js";
2
2
  import type { IBinaryWriter } from "../binary-encoding.js";
3
3
  import { WireType } from "../binary-encoding.js";
4
4
  /**
@@ -9,7 +9,7 @@ export declare function scalarEquals(type: ScalarType, a: string | boolean | num
9
9
  * Returns the default value for the given scalar type, following
10
10
  * proto3 semantics.
11
11
  */
12
- export declare function scalarDefaultValue(type: ScalarType): any;
12
+ export declare function scalarDefaultValue(type: ScalarType, longType: LongType): any;
13
13
  /**
14
14
  * Get information for writing a scalar value.
15
15
  *
@@ -61,7 +61,7 @@ exports.scalarEquals = scalarEquals;
61
61
  * Returns the default value for the given scalar type, following
62
62
  * proto3 semantics.
63
63
  */
64
- function scalarDefaultValue(type) {
64
+ function scalarDefaultValue(type, longType) {
65
65
  switch (type) {
66
66
  case field_js_1.ScalarType.BOOL:
67
67
  return false;
@@ -70,7 +70,8 @@ function scalarDefaultValue(type) {
70
70
  case field_js_1.ScalarType.INT64:
71
71
  case field_js_1.ScalarType.SFIXED64:
72
72
  case field_js_1.ScalarType.SINT64:
73
- return proto_int64_js_1.protoInt64.zero;
73
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison -- acceptable since it's covered by tests
74
+ return longType == 0 ? proto_int64_js_1.protoInt64.zero : "0";
74
75
  case field_js_1.ScalarType.DOUBLE:
75
76
  case field_js_1.ScalarType.FLOAT:
76
77
  return 0.0;
@@ -115,13 +116,13 @@ function scalarTypeInfo(type, value) {
115
116
  wireType = binary_encoding_js_1.WireType.Bit32;
116
117
  break;
117
118
  case field_js_1.ScalarType.INT64:
118
- isIntrinsicDefault = isUndefined || value == 0;
119
+ isIntrinsicDefault = isUndefined || value == 0; // Loose comparison matches 0n, 0 and "0"
119
120
  break;
120
121
  case field_js_1.ScalarType.UINT64:
121
- isIntrinsicDefault = isUndefined || value == 0;
122
+ isIntrinsicDefault = isUndefined || value == 0; // Loose comparison matches 0n, 0 and "0"
122
123
  break;
123
124
  case field_js_1.ScalarType.FIXED64:
124
- isIntrinsicDefault = isUndefined || value == 0;
125
+ isIntrinsicDefault = isUndefined || value == 0; // Loose comparison matches 0n, 0 and "0"
125
126
  wireType = binary_encoding_js_1.WireType.Bit64;
126
127
  break;
127
128
  case field_js_1.ScalarType.BYTES: