@bufbuild/protobuf 1.3.3 → 1.4.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.
Files changed (68) hide show
  1. package/dist/cjs/codegen-info.d.ts +14 -9
  2. package/dist/cjs/codegen-info.js +2 -1
  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/options-map.d.ts +1 -1
  25. package/dist/cjs/private/reify-wkt.d.ts +2 -0
  26. package/dist/cjs/private/reify-wkt.js +2 -0
  27. package/dist/cjs/private/scalars.d.ts +2 -2
  28. package/dist/cjs/private/scalars.js +6 -5
  29. package/dist/cjs/proto2.js +6 -2
  30. package/dist/cjs/proto3.js +6 -3
  31. package/dist/cjs/to-plain-message.d.ts +5 -2
  32. package/dist/cjs/to-plain-message.js +7 -1
  33. package/dist/cjs/type-registry.d.ts +13 -0
  34. package/dist/esm/codegen-info.d.ts +14 -9
  35. package/dist/esm/codegen-info.js +3 -1
  36. package/dist/esm/create-descriptor-set.js +13 -7
  37. package/dist/esm/create-registry-from-desc.js +7 -7
  38. package/dist/esm/descriptor-set.d.ts +21 -1
  39. package/dist/esm/field.d.ts +52 -1
  40. package/dist/esm/field.js +28 -0
  41. package/dist/esm/google/protobuf/any_pb.d.ts +2 -1
  42. package/dist/esm/google/protobuf/any_pb.js +2 -1
  43. package/dist/esm/google/protobuf/compiler/plugin_pb.d.ts +18 -1
  44. package/dist/esm/google/protobuf/compiler/plugin_pb.js +19 -0
  45. package/dist/esm/google/protobuf/descriptor_pb.d.ts +250 -16
  46. package/dist/esm/google/protobuf/descriptor_pb.js +238 -6
  47. package/dist/esm/google/protobuf/duration_pb.js +1 -1
  48. package/dist/esm/google/protobuf/struct_pb.js +1 -1
  49. package/dist/esm/google/protobuf/type_pb.js +1 -1
  50. package/dist/esm/index.d.ts +1 -1
  51. package/dist/esm/index.js +1 -1
  52. package/dist/esm/json-format.d.ts +3 -1
  53. package/dist/esm/json-format.js +1 -1
  54. package/dist/esm/private/binary-format-common.d.ts +4 -4
  55. package/dist/esm/private/binary-format-common.js +17 -6
  56. package/dist/esm/private/json-format-common.d.ts +1 -1
  57. package/dist/esm/private/json-format-common.js +12 -8
  58. package/dist/esm/private/options-map.d.ts +1 -1
  59. package/dist/esm/private/reify-wkt.d.ts +2 -0
  60. package/dist/esm/private/reify-wkt.js +2 -0
  61. package/dist/esm/private/scalars.d.ts +2 -2
  62. package/dist/esm/private/scalars.js +7 -6
  63. package/dist/esm/proto2.js +6 -2
  64. package/dist/esm/proto3.js +7 -4
  65. package/dist/esm/to-plain-message.d.ts +5 -2
  66. package/dist/esm/to-plain-message.js +7 -1
  67. package/dist/esm/type-registry.d.ts +13 -0
  68. package/package.json +8 -1
@@ -267,10 +267,9 @@ export class ExtensionRangeOptions extends Message {
267
267
  */
268
268
  this.uninterpretedOption = [];
269
269
  /**
270
- * go/protobuf-stripping-extension-declarations
271
- * Like Metadata, but we use a repeated field to hold all extension
272
- * declarations. This should avoid the size increases of transforming a large
273
- * extension range into small ranges in generated binaries.
270
+ * For external users: DO NOT USE. We are in the process of open sourcing
271
+ * extension declaration and executing internal cleanups before it can be
272
+ * used externally.
274
273
  *
275
274
  * @generated from field: repeated google.protobuf.ExtensionRangeOptions.Declaration declaration = 2;
276
275
  */
@@ -295,6 +294,7 @@ ExtensionRangeOptions.typeName = "google.protobuf.ExtensionRangeOptions";
295
294
  ExtensionRangeOptions.fields = proto2.util.newFieldList(() => [
296
295
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
297
296
  { no: 2, name: "declaration", kind: "message", T: ExtensionRangeOptions_Declaration, repeated: true },
297
+ { no: 50, name: "features", kind: "message", T: FeatureSet, opt: true },
298
298
  { no: 3, name: "verification", kind: "enum", T: proto2.getEnumType(ExtensionRangeOptions_VerificationState), opt: true, default: ExtensionRangeOptions_VerificationState.UNVERIFIED },
299
299
  ]);
300
300
  /**
@@ -347,7 +347,6 @@ ExtensionRangeOptions_Declaration.fields = proto2.util.newFieldList(() => [
347
347
  { no: 1, name: "number", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
348
348
  { no: 2, name: "full_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
349
349
  { no: 3, name: "type", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
350
- { no: 4, name: "is_repeated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
351
350
  { no: 5, name: "reserved", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
352
351
  { no: 6, name: "repeated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
353
352
  ]);
@@ -798,6 +797,7 @@ FileOptions.fields = proto2.util.newFieldList(() => [
798
797
  { no: 41, name: "php_namespace", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
799
798
  { no: 44, name: "php_metadata_namespace", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
800
799
  { no: 45, name: "ruby_package", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
800
+ { no: 50, name: "features", kind: "message", T: FeatureSet, opt: true },
801
801
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
802
802
  ]);
803
803
  /**
@@ -869,6 +869,7 @@ MessageOptions.fields = proto2.util.newFieldList(() => [
869
869
  { no: 3, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
870
870
  { no: 7, name: "map_entry", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
871
871
  { no: 11, name: "deprecated_legacy_json_field_conflicts", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
872
+ { no: 12, name: "features", kind: "message", T: FeatureSet, opt: true },
872
873
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
873
874
  ]);
874
875
  /**
@@ -881,6 +882,10 @@ export class FieldOptions extends Message {
881
882
  * @generated from field: repeated google.protobuf.FieldOptions.OptionTargetType targets = 19;
882
883
  */
883
884
  this.targets = [];
885
+ /**
886
+ * @generated from field: repeated google.protobuf.FieldOptions.EditionDefault edition_defaults = 20;
887
+ */
888
+ this.editionDefaults = [];
884
889
  /**
885
890
  * The parser stores options it doesn't recognize here. See above.
886
891
  *
@@ -914,8 +919,9 @@ FieldOptions.fields = proto2.util.newFieldList(() => [
914
919
  { no: 10, name: "weak", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
915
920
  { no: 16, name: "debug_redact", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
916
921
  { no: 17, name: "retention", kind: "enum", T: proto2.getEnumType(FieldOptions_OptionRetention), opt: true },
917
- { no: 18, name: "target", kind: "enum", T: proto2.getEnumType(FieldOptions_OptionTargetType), opt: true },
918
922
  { no: 19, name: "targets", kind: "enum", T: proto2.getEnumType(FieldOptions_OptionTargetType), repeated: true },
923
+ { no: 20, name: "edition_defaults", kind: "message", T: FieldOptions_EditionDefault, repeated: true },
924
+ { no: 21, name: "features", kind: "message", T: FeatureSet, opt: true },
919
925
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
920
926
  ]);
921
927
  /**
@@ -1073,6 +1079,33 @@ proto2.util.setEnumType(FieldOptions_OptionTargetType, "google.protobuf.FieldOpt
1073
1079
  { no: 8, name: "TARGET_TYPE_SERVICE" },
1074
1080
  { no: 9, name: "TARGET_TYPE_METHOD" },
1075
1081
  ]);
1082
+ /**
1083
+ * @generated from message google.protobuf.FieldOptions.EditionDefault
1084
+ */
1085
+ export class FieldOptions_EditionDefault extends Message {
1086
+ constructor(data) {
1087
+ super();
1088
+ proto2.util.initPartial(data, this);
1089
+ }
1090
+ static fromBinary(bytes, options) {
1091
+ return new FieldOptions_EditionDefault().fromBinary(bytes, options);
1092
+ }
1093
+ static fromJson(jsonValue, options) {
1094
+ return new FieldOptions_EditionDefault().fromJson(jsonValue, options);
1095
+ }
1096
+ static fromJsonString(jsonString, options) {
1097
+ return new FieldOptions_EditionDefault().fromJsonString(jsonString, options);
1098
+ }
1099
+ static equals(a, b) {
1100
+ return proto2.util.equals(FieldOptions_EditionDefault, a, b);
1101
+ }
1102
+ }
1103
+ FieldOptions_EditionDefault.runtime = proto2;
1104
+ FieldOptions_EditionDefault.typeName = "google.protobuf.FieldOptions.EditionDefault";
1105
+ FieldOptions_EditionDefault.fields = proto2.util.newFieldList(() => [
1106
+ { no: 1, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
1107
+ { no: 2, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
1108
+ ]);
1076
1109
  /**
1077
1110
  * @generated from message google.protobuf.OneofOptions
1078
1111
  */
@@ -1103,6 +1136,7 @@ export class OneofOptions extends Message {
1103
1136
  OneofOptions.runtime = proto2;
1104
1137
  OneofOptions.typeName = "google.protobuf.OneofOptions";
1105
1138
  OneofOptions.fields = proto2.util.newFieldList(() => [
1139
+ { no: 1, name: "features", kind: "message", T: FeatureSet, opt: true },
1106
1140
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
1107
1141
  ]);
1108
1142
  /**
@@ -1138,6 +1172,7 @@ EnumOptions.fields = proto2.util.newFieldList(() => [
1138
1172
  { no: 2, name: "allow_alias", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
1139
1173
  { no: 3, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
1140
1174
  { no: 6, name: "deprecated_legacy_json_field_conflicts", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
1175
+ { no: 7, name: "features", kind: "message", T: FeatureSet, opt: true },
1141
1176
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
1142
1177
  ]);
1143
1178
  /**
@@ -1171,6 +1206,8 @@ EnumValueOptions.runtime = proto2;
1171
1206
  EnumValueOptions.typeName = "google.protobuf.EnumValueOptions";
1172
1207
  EnumValueOptions.fields = proto2.util.newFieldList(() => [
1173
1208
  { no: 1, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
1209
+ { no: 2, name: "features", kind: "message", T: FeatureSet, opt: true },
1210
+ { no: 3, name: "debug_redact", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
1174
1211
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
1175
1212
  ]);
1176
1213
  /**
@@ -1203,6 +1240,7 @@ export class ServiceOptions extends Message {
1203
1240
  ServiceOptions.runtime = proto2;
1204
1241
  ServiceOptions.typeName = "google.protobuf.ServiceOptions";
1205
1242
  ServiceOptions.fields = proto2.util.newFieldList(() => [
1243
+ { no: 34, name: "features", kind: "message", T: FeatureSet, opt: true },
1206
1244
  { no: 33, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
1207
1245
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
1208
1246
  ]);
@@ -1238,6 +1276,7 @@ MethodOptions.typeName = "google.protobuf.MethodOptions";
1238
1276
  MethodOptions.fields = proto2.util.newFieldList(() => [
1239
1277
  { no: 33, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
1240
1278
  { no: 34, name: "idempotency_level", kind: "enum", T: proto2.getEnumType(MethodOptions_IdempotencyLevel), opt: true, default: MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN },
1279
+ { no: 35, name: "features", kind: "message", T: FeatureSet, opt: true },
1241
1280
  { no: 999, name: "uninterpreted_option", kind: "message", T: UninterpretedOption, repeated: true },
1242
1281
  ]);
1243
1282
  /**
@@ -1348,6 +1387,199 @@ UninterpretedOption_NamePart.fields = proto2.util.newFieldList(() => [
1348
1387
  { no: 1, name: "name_part", kind: "scalar", T: 9 /* ScalarType.STRING */ },
1349
1388
  { no: 2, name: "is_extension", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
1350
1389
  ]);
1390
+ /**
1391
+ * TODO(b/274655146) Enums in C++ gencode (and potentially other languages) are
1392
+ * not well scoped. This means that each of the feature enums below can clash
1393
+ * with each other. The short names we've chosen maximize call-site
1394
+ * readability, but leave us very open to this scenario. A future feature will
1395
+ * be designed and implemented to handle this, hopefully before we ever hit a
1396
+ * conflict here.
1397
+ *
1398
+ * @generated from message google.protobuf.FeatureSet
1399
+ */
1400
+ export class FeatureSet extends Message {
1401
+ constructor(data) {
1402
+ super();
1403
+ proto2.util.initPartial(data, this);
1404
+ }
1405
+ static fromBinary(bytes, options) {
1406
+ return new FeatureSet().fromBinary(bytes, options);
1407
+ }
1408
+ static fromJson(jsonValue, options) {
1409
+ return new FeatureSet().fromJson(jsonValue, options);
1410
+ }
1411
+ static fromJsonString(jsonString, options) {
1412
+ return new FeatureSet().fromJsonString(jsonString, options);
1413
+ }
1414
+ static equals(a, b) {
1415
+ return proto2.util.equals(FeatureSet, a, b);
1416
+ }
1417
+ }
1418
+ FeatureSet.runtime = proto2;
1419
+ FeatureSet.typeName = "google.protobuf.FeatureSet";
1420
+ FeatureSet.fields = proto2.util.newFieldList(() => [
1421
+ { no: 1, name: "field_presence", kind: "enum", T: proto2.getEnumType(FeatureSet_FieldPresence), opt: true },
1422
+ { no: 2, name: "enum_type", kind: "enum", T: proto2.getEnumType(FeatureSet_EnumType), opt: true },
1423
+ { no: 3, name: "repeated_field_encoding", kind: "enum", T: proto2.getEnumType(FeatureSet_RepeatedFieldEncoding), opt: true },
1424
+ { no: 4, name: "string_field_validation", kind: "enum", T: proto2.getEnumType(FeatureSet_StringFieldValidation), opt: true },
1425
+ { no: 5, name: "message_encoding", kind: "enum", T: proto2.getEnumType(FeatureSet_MessageEncoding), opt: true },
1426
+ { no: 6, name: "json_format", kind: "enum", T: proto2.getEnumType(FeatureSet_JsonFormat), opt: true },
1427
+ { no: 999, name: "raw_features", kind: "message", T: FeatureSet, opt: true },
1428
+ ]);
1429
+ /**
1430
+ * @generated from enum google.protobuf.FeatureSet.FieldPresence
1431
+ */
1432
+ export var FeatureSet_FieldPresence;
1433
+ (function (FeatureSet_FieldPresence) {
1434
+ /**
1435
+ * @generated from enum value: FIELD_PRESENCE_UNKNOWN = 0;
1436
+ */
1437
+ FeatureSet_FieldPresence[FeatureSet_FieldPresence["FIELD_PRESENCE_UNKNOWN"] = 0] = "FIELD_PRESENCE_UNKNOWN";
1438
+ /**
1439
+ * @generated from enum value: EXPLICIT = 1;
1440
+ */
1441
+ FeatureSet_FieldPresence[FeatureSet_FieldPresence["EXPLICIT"] = 1] = "EXPLICIT";
1442
+ /**
1443
+ * @generated from enum value: IMPLICIT = 2;
1444
+ */
1445
+ FeatureSet_FieldPresence[FeatureSet_FieldPresence["IMPLICIT"] = 2] = "IMPLICIT";
1446
+ /**
1447
+ * @generated from enum value: LEGACY_REQUIRED = 3;
1448
+ */
1449
+ FeatureSet_FieldPresence[FeatureSet_FieldPresence["LEGACY_REQUIRED"] = 3] = "LEGACY_REQUIRED";
1450
+ })(FeatureSet_FieldPresence || (FeatureSet_FieldPresence = {}));
1451
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_FieldPresence)
1452
+ proto2.util.setEnumType(FeatureSet_FieldPresence, "google.protobuf.FeatureSet.FieldPresence", [
1453
+ { no: 0, name: "FIELD_PRESENCE_UNKNOWN" },
1454
+ { no: 1, name: "EXPLICIT" },
1455
+ { no: 2, name: "IMPLICIT" },
1456
+ { no: 3, name: "LEGACY_REQUIRED" },
1457
+ ]);
1458
+ /**
1459
+ * @generated from enum google.protobuf.FeatureSet.EnumType
1460
+ */
1461
+ export var FeatureSet_EnumType;
1462
+ (function (FeatureSet_EnumType) {
1463
+ /**
1464
+ * @generated from enum value: ENUM_TYPE_UNKNOWN = 0;
1465
+ */
1466
+ FeatureSet_EnumType[FeatureSet_EnumType["ENUM_TYPE_UNKNOWN"] = 0] = "ENUM_TYPE_UNKNOWN";
1467
+ /**
1468
+ * @generated from enum value: OPEN = 1;
1469
+ */
1470
+ FeatureSet_EnumType[FeatureSet_EnumType["OPEN"] = 1] = "OPEN";
1471
+ /**
1472
+ * @generated from enum value: CLOSED = 2;
1473
+ */
1474
+ FeatureSet_EnumType[FeatureSet_EnumType["CLOSED"] = 2] = "CLOSED";
1475
+ })(FeatureSet_EnumType || (FeatureSet_EnumType = {}));
1476
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_EnumType)
1477
+ proto2.util.setEnumType(FeatureSet_EnumType, "google.protobuf.FeatureSet.EnumType", [
1478
+ { no: 0, name: "ENUM_TYPE_UNKNOWN" },
1479
+ { no: 1, name: "OPEN" },
1480
+ { no: 2, name: "CLOSED" },
1481
+ ]);
1482
+ /**
1483
+ * @generated from enum google.protobuf.FeatureSet.RepeatedFieldEncoding
1484
+ */
1485
+ export var FeatureSet_RepeatedFieldEncoding;
1486
+ (function (FeatureSet_RepeatedFieldEncoding) {
1487
+ /**
1488
+ * @generated from enum value: REPEATED_FIELD_ENCODING_UNKNOWN = 0;
1489
+ */
1490
+ FeatureSet_RepeatedFieldEncoding[FeatureSet_RepeatedFieldEncoding["REPEATED_FIELD_ENCODING_UNKNOWN"] = 0] = "REPEATED_FIELD_ENCODING_UNKNOWN";
1491
+ /**
1492
+ * @generated from enum value: PACKED = 1;
1493
+ */
1494
+ FeatureSet_RepeatedFieldEncoding[FeatureSet_RepeatedFieldEncoding["PACKED"] = 1] = "PACKED";
1495
+ /**
1496
+ * @generated from enum value: EXPANDED = 2;
1497
+ */
1498
+ FeatureSet_RepeatedFieldEncoding[FeatureSet_RepeatedFieldEncoding["EXPANDED"] = 2] = "EXPANDED";
1499
+ })(FeatureSet_RepeatedFieldEncoding || (FeatureSet_RepeatedFieldEncoding = {}));
1500
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_RepeatedFieldEncoding)
1501
+ proto2.util.setEnumType(FeatureSet_RepeatedFieldEncoding, "google.protobuf.FeatureSet.RepeatedFieldEncoding", [
1502
+ { no: 0, name: "REPEATED_FIELD_ENCODING_UNKNOWN" },
1503
+ { no: 1, name: "PACKED" },
1504
+ { no: 2, name: "EXPANDED" },
1505
+ ]);
1506
+ /**
1507
+ * @generated from enum google.protobuf.FeatureSet.StringFieldValidation
1508
+ */
1509
+ export var FeatureSet_StringFieldValidation;
1510
+ (function (FeatureSet_StringFieldValidation) {
1511
+ /**
1512
+ * @generated from enum value: STRING_FIELD_VALIDATION_UNKNOWN = 0;
1513
+ */
1514
+ FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["STRING_FIELD_VALIDATION_UNKNOWN"] = 0] = "STRING_FIELD_VALIDATION_UNKNOWN";
1515
+ /**
1516
+ * @generated from enum value: MANDATORY = 1;
1517
+ */
1518
+ FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["MANDATORY"] = 1] = "MANDATORY";
1519
+ /**
1520
+ * @generated from enum value: HINT = 2;
1521
+ */
1522
+ FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["HINT"] = 2] = "HINT";
1523
+ /**
1524
+ * @generated from enum value: NONE = 3;
1525
+ */
1526
+ FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["NONE"] = 3] = "NONE";
1527
+ })(FeatureSet_StringFieldValidation || (FeatureSet_StringFieldValidation = {}));
1528
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_StringFieldValidation)
1529
+ proto2.util.setEnumType(FeatureSet_StringFieldValidation, "google.protobuf.FeatureSet.StringFieldValidation", [
1530
+ { no: 0, name: "STRING_FIELD_VALIDATION_UNKNOWN" },
1531
+ { no: 1, name: "MANDATORY" },
1532
+ { no: 2, name: "HINT" },
1533
+ { no: 3, name: "NONE" },
1534
+ ]);
1535
+ /**
1536
+ * @generated from enum google.protobuf.FeatureSet.MessageEncoding
1537
+ */
1538
+ export var FeatureSet_MessageEncoding;
1539
+ (function (FeatureSet_MessageEncoding) {
1540
+ /**
1541
+ * @generated from enum value: MESSAGE_ENCODING_UNKNOWN = 0;
1542
+ */
1543
+ FeatureSet_MessageEncoding[FeatureSet_MessageEncoding["MESSAGE_ENCODING_UNKNOWN"] = 0] = "MESSAGE_ENCODING_UNKNOWN";
1544
+ /**
1545
+ * @generated from enum value: LENGTH_PREFIXED = 1;
1546
+ */
1547
+ FeatureSet_MessageEncoding[FeatureSet_MessageEncoding["LENGTH_PREFIXED"] = 1] = "LENGTH_PREFIXED";
1548
+ /**
1549
+ * @generated from enum value: DELIMITED = 2;
1550
+ */
1551
+ FeatureSet_MessageEncoding[FeatureSet_MessageEncoding["DELIMITED"] = 2] = "DELIMITED";
1552
+ })(FeatureSet_MessageEncoding || (FeatureSet_MessageEncoding = {}));
1553
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_MessageEncoding)
1554
+ proto2.util.setEnumType(FeatureSet_MessageEncoding, "google.protobuf.FeatureSet.MessageEncoding", [
1555
+ { no: 0, name: "MESSAGE_ENCODING_UNKNOWN" },
1556
+ { no: 1, name: "LENGTH_PREFIXED" },
1557
+ { no: 2, name: "DELIMITED" },
1558
+ ]);
1559
+ /**
1560
+ * @generated from enum google.protobuf.FeatureSet.JsonFormat
1561
+ */
1562
+ export var FeatureSet_JsonFormat;
1563
+ (function (FeatureSet_JsonFormat) {
1564
+ /**
1565
+ * @generated from enum value: JSON_FORMAT_UNKNOWN = 0;
1566
+ */
1567
+ FeatureSet_JsonFormat[FeatureSet_JsonFormat["JSON_FORMAT_UNKNOWN"] = 0] = "JSON_FORMAT_UNKNOWN";
1568
+ /**
1569
+ * @generated from enum value: ALLOW = 1;
1570
+ */
1571
+ FeatureSet_JsonFormat[FeatureSet_JsonFormat["ALLOW"] = 1] = "ALLOW";
1572
+ /**
1573
+ * @generated from enum value: LEGACY_BEST_EFFORT = 2;
1574
+ */
1575
+ FeatureSet_JsonFormat[FeatureSet_JsonFormat["LEGACY_BEST_EFFORT"] = 2] = "LEGACY_BEST_EFFORT";
1576
+ })(FeatureSet_JsonFormat || (FeatureSet_JsonFormat = {}));
1577
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_JsonFormat)
1578
+ proto2.util.setEnumType(FeatureSet_JsonFormat, "google.protobuf.FeatureSet.JsonFormat", [
1579
+ { no: 0, name: "JSON_FORMAT_UNKNOWN" },
1580
+ { no: 1, name: "ALLOW" },
1581
+ { no: 2, name: "LEGACY_BEST_EFFORT" },
1582
+ ]);
1351
1583
  /**
1352
1584
  * Encapsulates information about the original source file from which a
1353
1585
  * FileDescriptorProto was generated.
@@ -138,7 +138,7 @@ export class Duration extends Message {
138
138
  nanosStr = nanosStr.substring(0, 6);
139
139
  }
140
140
  text += "." + nanosStr;
141
- if (this.nanos < 0 && this.seconds === protoInt64.zero) {
141
+ if (this.nanos < 0 && Number(this.seconds) == 0) {
142
142
  text = "-" + text;
143
143
  }
144
144
  }
@@ -11,7 +11,7 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- // @generated by protoc-gen-es v1.3.3 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
14
+ // @generated by protoc-gen-es v1.4.1 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
15
15
  // @generated from file google/protobuf/struct.proto (package google.protobuf, syntax proto3)
16
16
  /* eslint-disable */
17
17
  import { proto3 } from "../../proto3.js";
@@ -11,7 +11,7 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- // @generated by protoc-gen-es v1.3.3 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
14
+ // @generated by protoc-gen-es v1.4.1 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
15
15
  // @generated from file google/protobuf/type.proto (package google.protobuf, syntax proto3)
16
16
  /* eslint-disable */
17
17
  import { proto3 } from "../../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/esm/index.js CHANGED
@@ -19,7 +19,7 @@ export { protoBase64 } from "./proto-base64.js";
19
19
  export { protoDelimited } from "./proto-delimited.js";
20
20
  export { codegenInfo } from "./codegen-info.js";
21
21
  export { Message } from "./message.js";
22
- export { ScalarType } from "./field.js";
22
+ export { ScalarType, LongType } from "./field.js";
23
23
  export { MethodKind, MethodIdempotency } from "./service-type.js";
24
24
  export { WireType, BinaryWriter, BinaryReader } from "./binary-encoding.js";
25
25
  export { createDescriptorSet } from "./create-descriptor-set.js";
@@ -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
  */
@@ -11,4 +11,4 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- export {};
14
+ import { LongType } from "./field.js";
@@ -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
  // limitations under the License.
14
14
  import { BinaryReader, BinaryWriter, WireType } from "../binary-encoding.js";
15
15
  import { Message } from "../message.js";
16
- import { ScalarType } from "../field.js";
16
+ import { LongType, ScalarType } from "../field.js";
17
17
  import { wrapField } from "./field-wrapper.js";
18
18
  import { scalarDefaultValue, scalarTypeInfo } from "./scalars.js";
19
19
  import { assert } from "./assert.js";
@@ -87,6 +87,11 @@ export function makeBinaryFormatCommon() {
87
87
  case "scalar":
88
88
  case "enum":
89
89
  const scalarType = field.kind == "enum" ? ScalarType.INT32 : field.T;
90
+ let read = readScalar;
91
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison -- acceptable since it's covered by tests
92
+ if (field.kind == "scalar" && field.L > 0) {
93
+ read = readScalarLTString;
94
+ }
90
95
  if (repeated) {
91
96
  let arr = target[localName]; // safe to assume presence of array, oneof cannot contain repeated values
92
97
  if (wireType == WireType.LengthDelimited &&
@@ -94,15 +99,15 @@ export function makeBinaryFormatCommon() {
94
99
  scalarType != ScalarType.BYTES) {
95
100
  let e = reader.uint32() + reader.pos;
96
101
  while (reader.pos < e) {
97
- arr.push(readScalar(reader, scalarType));
102
+ arr.push(read(reader, scalarType));
98
103
  }
99
104
  }
100
105
  else {
101
- arr.push(readScalar(reader, scalarType));
106
+ arr.push(read(reader, scalarType));
102
107
  }
103
108
  }
104
109
  else {
105
- target[localName] = readScalar(reader, scalarType);
110
+ target[localName] = read(reader, scalarType);
106
111
  }
107
112
  break;
108
113
  case "message":
@@ -168,7 +173,7 @@ function readMapEntry(field, reader, options) {
168
173
  }
169
174
  }
170
175
  if (key === undefined) {
171
- let keyRaw = scalarDefaultValue(field.K);
176
+ let keyRaw = scalarDefaultValue(field.K, LongType.BIGINT);
172
177
  key =
173
178
  field.K == ScalarType.BOOL
174
179
  ? keyRaw.toString()
@@ -180,7 +185,7 @@ function readMapEntry(field, reader, options) {
180
185
  if (val === undefined) {
181
186
  switch (field.V.kind) {
182
187
  case "scalar":
183
- val = scalarDefaultValue(field.V.T);
188
+ val = scalarDefaultValue(field.V.T, LongType.BIGINT);
184
189
  break;
185
190
  case "enum":
186
191
  val = 0;
@@ -192,6 +197,12 @@ function readMapEntry(field, reader, options) {
192
197
  }
193
198
  return [key, val];
194
199
  }
200
+ // Read a scalar value, but return 64 bit integral types (int64, uint64,
201
+ // sint64, fixed64, sfixed64) as string instead of bigint.
202
+ export function readScalarLTString(reader, type) {
203
+ const v = readScalar(reader, type);
204
+ return typeof v == "bigint" ? v.toString() : v;
205
+ }
195
206
  // Does not use scalarTypeInfo() for better performance.
196
207
  function readScalar(reader, type) {
197
208
  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;
@@ -12,7 +12,7 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
  import { Message } from "../message.js";
15
- import { ScalarType } from "../field.js";
15
+ import { LongType, ScalarType } from "../field.js";
16
16
  import { assert, assertFloat32, assertInt32, assertUInt32 } from "./assert.js";
17
17
  import { protoInt64 } from "../proto-int64.js";
18
18
  import { protoBase64 } from "../proto-base64.js";
@@ -93,7 +93,7 @@ export function makeJsonFormatCommon(makeWriteField) {
93
93
  break;
94
94
  case "scalar":
95
95
  try {
96
- val = readScalar(field.T, jsonItem);
96
+ val = readScalar(field.T, jsonItem, field.L);
97
97
  }
98
98
  catch (e) {
99
99
  let m = `cannot decode field ${type.typeName}.${field.name} from JSON: ${this.debug(jsonItem)}`;
@@ -131,7 +131,7 @@ export function makeJsonFormatCommon(makeWriteField) {
131
131
  break;
132
132
  case "scalar":
133
133
  try {
134
- val = readScalar(field.V.T, jsonMapValue);
134
+ val = readScalar(field.V.T, jsonMapValue, LongType.BIGINT);
135
135
  }
136
136
  catch (e) {
137
137
  let m = `cannot decode map value for field ${type.typeName}.${field.name} from JSON: ${this.debug(jsonValue)}`;
@@ -149,7 +149,7 @@ export function makeJsonFormatCommon(makeWriteField) {
149
149
  : jsonMapKey == "false"
150
150
  ? false
151
151
  : jsonMapKey
152
- : jsonMapKey).toString()] = val;
152
+ : jsonMapKey, LongType.BIGINT).toString()] = val;
153
153
  }
154
154
  catch (e) {
155
155
  let m = `cannot decode map key for field ${type.typeName}.${field.name} from JSON: ${this.debug(jsonValue)}`;
@@ -189,7 +189,7 @@ export function makeJsonFormatCommon(makeWriteField) {
189
189
  break;
190
190
  case "scalar":
191
191
  try {
192
- target[localName] = readScalar(field.T, jsonValue);
192
+ target[localName] = readScalar(field.T, jsonValue, field.L);
193
193
  }
194
194
  catch (e) {
195
195
  let m = `cannot decode field ${type.typeName}.${field.name} from JSON: ${this.debug(jsonValue)}`;
@@ -261,7 +261,7 @@ function debugJsonValue(json) {
261
261
  }
262
262
  // May throw an error. If the error message is non-blank, it should be shown.
263
263
  // It is up to the caller to provide context.
264
- function readScalar(type, json) {
264
+ function readScalar(type, json, longType) {
265
265
  // every valid case in the switch below returns, and every fall
266
266
  // through is regarded as a failure.
267
267
  switch (type) {
@@ -330,14 +330,18 @@ function readScalar(type, json) {
330
330
  return protoInt64.zero;
331
331
  if (typeof json != "number" && typeof json != "string")
332
332
  break;
333
- return protoInt64.parse(json);
333
+ const long = protoInt64.parse(json);
334
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
335
+ return longType ? long.toString() : long;
334
336
  case ScalarType.FIXED64:
335
337
  case ScalarType.UINT64:
336
338
  if (json === null)
337
339
  return protoInt64.zero;
338
340
  if (typeof json != "number" && typeof json != "string")
339
341
  break;
340
- return protoInt64.uParse(json);
342
+ const uLong = protoInt64.uParse(json);
343
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
344
+ return longType ? uLong.toString() : uLong;
341
345
  // bool:
342
346
  case ScalarType.BOOL:
343
347
  if (json === null)
@@ -1,4 +1,4 @@
1
- import type { JsonValue } from "../json-format";
1
+ import type { JsonValue } from "../json-format.js";
2
2
  /**
3
3
  *
4
4
  */
@@ -86,6 +86,8 @@ type DescWkt = {
86
86
  };
87
87
  };
88
88
  /**
89
+ * @deprecated please use reifyWkt from @bufbuild/protoplugin/ecmascript instead
90
+ *
89
91
  * Reifies a given DescMessage into a more concrete object representing its
90
92
  * respective well-known type. The returned object will contain properties
91
93
  * representing the WKT's defined fields.
@@ -13,6 +13,8 @@
13
13
  // limitations under the License.
14
14
  import { ScalarType } from "../field.js";
15
15
  /**
16
+ * @deprecated please use reifyWkt from @bufbuild/protoplugin/ecmascript instead
17
+ *
16
18
  * Reifies a given DescMessage into a more concrete object representing its
17
19
  * respective well-known type. The returned object will contain properties
18
20
  * representing the WKT's defined fields.
@@ -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
  *