@bufbuild/protobuf 1.4.0 → 1.4.2

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.
@@ -11,8 +11,88 @@
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
- import { Message } from "../../message.js";
14
+ // Author: kenton@google.com (Kenton Varda)
15
+ // Based on original Protocol Buffers design by
16
+ // Sanjay Ghemawat, Jeff Dean, and others.
17
+ //
18
+ // The messages in this file describe the definitions found in .proto files.
19
+ // A valid .proto file can be translated directly to a FileDescriptorProto
20
+ // without any other information (e.g. without reading its imports).
21
+ // @generated by protoc-gen-es v1.4.2 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
22
+ // @generated from file google/protobuf/descriptor.proto (package google.protobuf, syntax proto2)
23
+ /* eslint-disable */
15
24
  import { proto2 } from "../../proto2.js";
25
+ import { Message } from "../../message.js";
26
+ /**
27
+ * The full set of known editions.
28
+ *
29
+ * @generated from enum google.protobuf.Edition
30
+ */
31
+ export var Edition;
32
+ (function (Edition) {
33
+ /**
34
+ * A placeholder for an unknown edition value.
35
+ *
36
+ * @generated from enum value: EDITION_UNKNOWN = 0;
37
+ */
38
+ Edition[Edition["EDITION_UNKNOWN"] = 0] = "EDITION_UNKNOWN";
39
+ /**
40
+ * Legacy syntax "editions". These pre-date editions, but behave much like
41
+ * distinct editions. These can't be used to specify the edition of proto
42
+ * files, but feature definitions must supply proto2/proto3 defaults for
43
+ * backwards compatibility.
44
+ *
45
+ * @generated from enum value: EDITION_PROTO2 = 998;
46
+ */
47
+ Edition[Edition["EDITION_PROTO2"] = 998] = "EDITION_PROTO2";
48
+ /**
49
+ * @generated from enum value: EDITION_PROTO3 = 999;
50
+ */
51
+ Edition[Edition["EDITION_PROTO3"] = 999] = "EDITION_PROTO3";
52
+ /**
53
+ * Editions that have been released. The specific values are arbitrary and
54
+ * should not be depended on, but they will always be time-ordered for easy
55
+ * comparison.
56
+ *
57
+ * @generated from enum value: EDITION_2023 = 1000;
58
+ */
59
+ Edition[Edition["EDITION_2023"] = 1000] = "EDITION_2023";
60
+ /**
61
+ * Placeholder editions for testing feature resolution. These should not be
62
+ * used or relyed on outside of tests.
63
+ *
64
+ * @generated from enum value: EDITION_1_TEST_ONLY = 1;
65
+ */
66
+ Edition[Edition["EDITION_1_TEST_ONLY"] = 1] = "EDITION_1_TEST_ONLY";
67
+ /**
68
+ * @generated from enum value: EDITION_2_TEST_ONLY = 2;
69
+ */
70
+ Edition[Edition["EDITION_2_TEST_ONLY"] = 2] = "EDITION_2_TEST_ONLY";
71
+ /**
72
+ * @generated from enum value: EDITION_99997_TEST_ONLY = 99997;
73
+ */
74
+ Edition[Edition["EDITION_99997_TEST_ONLY"] = 99997] = "EDITION_99997_TEST_ONLY";
75
+ /**
76
+ * @generated from enum value: EDITION_99998_TEST_ONLY = 99998;
77
+ */
78
+ Edition[Edition["EDITION_99998_TEST_ONLY"] = 99998] = "EDITION_99998_TEST_ONLY";
79
+ /**
80
+ * @generated from enum value: EDITION_99999_TEST_ONLY = 99999;
81
+ */
82
+ Edition[Edition["EDITION_99999_TEST_ONLY"] = 99999] = "EDITION_99999_TEST_ONLY";
83
+ })(Edition || (Edition = {}));
84
+ // Retrieve enum metadata with: proto2.getEnumType(Edition)
85
+ proto2.util.setEnumType(Edition, "google.protobuf.Edition", [
86
+ { no: 0, name: "EDITION_UNKNOWN" },
87
+ { no: 998, name: "EDITION_PROTO2" },
88
+ { no: 999, name: "EDITION_PROTO3" },
89
+ { no: 1000, name: "EDITION_2023" },
90
+ { no: 1, name: "EDITION_1_TEST_ONLY" },
91
+ { no: 2, name: "EDITION_2_TEST_ONLY" },
92
+ { no: 99997, name: "EDITION_99997_TEST_ONLY" },
93
+ { no: 99998, name: "EDITION_99998_TEST_ONLY" },
94
+ { no: 99999, name: "EDITION_99999_TEST_ONLY" },
95
+ ]);
16
96
  /**
17
97
  * The protocol compiler can output a FileDescriptorSet containing the .proto
18
98
  * files it parses.
@@ -121,7 +201,7 @@ FileDescriptorProto.fields = proto2.util.newFieldList(() => [
121
201
  { no: 8, name: "options", kind: "message", T: FileOptions, opt: true },
122
202
  { no: 9, name: "source_code_info", kind: "message", T: SourceCodeInfo, opt: true },
123
203
  { no: 12, name: "syntax", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
124
- { no: 13, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
204
+ { no: 14, name: "edition", kind: "enum", T: proto2.getEnumType(Edition), opt: true },
125
205
  ]);
126
206
  /**
127
207
  * Describes a message type.
@@ -440,9 +520,10 @@ export var FieldDescriptorProto_Type;
440
520
  FieldDescriptorProto_Type[FieldDescriptorProto_Type["STRING"] = 9] = "STRING";
441
521
  /**
442
522
  * Tag-delimited aggregate.
443
- * Group type is deprecated and not supported in proto3. However, Proto3
523
+ * Group type is deprecated and not supported after google.protobuf. However, Proto3
444
524
  * implementations should still be able to parse the group wire format and
445
- * treat group fields as unknown fields.
525
+ * treat group fields as unknown fields. In Editions, the group wire format
526
+ * can be enabled via the `message_encoding` feature.
446
527
  *
447
528
  * @generated from enum value: TYPE_GROUP = 10;
448
529
  */
@@ -520,20 +601,24 @@ export var FieldDescriptorProto_Label;
520
601
  * @generated from enum value: LABEL_OPTIONAL = 1;
521
602
  */
522
603
  FieldDescriptorProto_Label[FieldDescriptorProto_Label["OPTIONAL"] = 1] = "OPTIONAL";
523
- /**
524
- * @generated from enum value: LABEL_REQUIRED = 2;
525
- */
526
- FieldDescriptorProto_Label[FieldDescriptorProto_Label["REQUIRED"] = 2] = "REQUIRED";
527
604
  /**
528
605
  * @generated from enum value: LABEL_REPEATED = 3;
529
606
  */
530
607
  FieldDescriptorProto_Label[FieldDescriptorProto_Label["REPEATED"] = 3] = "REPEATED";
608
+ /**
609
+ * The required label is only allowed in google.protobuf. In proto3 and Editions
610
+ * it's explicitly prohibited. In Editions, the `field_presence` feature
611
+ * can be used to get this behavior.
612
+ *
613
+ * @generated from enum value: LABEL_REQUIRED = 2;
614
+ */
615
+ FieldDescriptorProto_Label[FieldDescriptorProto_Label["REQUIRED"] = 2] = "REQUIRED";
531
616
  })(FieldDescriptorProto_Label || (FieldDescriptorProto_Label = {}));
532
617
  // Retrieve enum metadata with: proto2.getEnumType(FieldDescriptorProto_Label)
533
618
  proto2.util.setEnumType(FieldDescriptorProto_Label, "google.protobuf.FieldDescriptorProto.Label", [
534
619
  { no: 1, name: "LABEL_OPTIONAL" },
535
- { no: 2, name: "LABEL_REQUIRED" },
536
620
  { no: 3, name: "LABEL_REPEATED" },
621
+ { no: 2, name: "LABEL_REQUIRED" },
537
622
  ]);
538
623
  /**
539
624
  * Describes a oneof.
@@ -1103,7 +1188,7 @@ export class FieldOptions_EditionDefault extends Message {
1103
1188
  FieldOptions_EditionDefault.runtime = proto2;
1104
1189
  FieldOptions_EditionDefault.typeName = "google.protobuf.FieldOptions.EditionDefault";
1105
1190
  FieldOptions_EditionDefault.fields = proto2.util.newFieldList(() => [
1106
- { no: 1, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
1191
+ { no: 3, name: "edition", kind: "enum", T: proto2.getEnumType(Edition), opt: true },
1107
1192
  { no: 2, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
1108
1193
  ]);
1109
1194
  /**
@@ -1388,7 +1473,7 @@ UninterpretedOption_NamePart.fields = proto2.util.newFieldList(() => [
1388
1473
  { no: 2, name: "is_extension", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
1389
1474
  ]);
1390
1475
  /**
1391
- * TODO(b/274655146) Enums in C++ gencode (and potentially other languages) are
1476
+ * TODO Enums in C++ gencode (and potentially other languages) are
1392
1477
  * not well scoped. This means that each of the feature enums below can clash
1393
1478
  * with each other. The short names we've chosen maximize call-site
1394
1479
  * readability, but leave us very open to this scenario. A future feature will
@@ -1421,10 +1506,9 @@ FeatureSet.fields = proto2.util.newFieldList(() => [
1421
1506
  { no: 1, name: "field_presence", kind: "enum", T: proto2.getEnumType(FeatureSet_FieldPresence), opt: true },
1422
1507
  { no: 2, name: "enum_type", kind: "enum", T: proto2.getEnumType(FeatureSet_EnumType), opt: true },
1423
1508
  { 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 },
1509
+ { no: 4, name: "utf8_validation", kind: "enum", T: proto2.getEnumType(FeatureSet_Utf8Validation), opt: true },
1425
1510
  { no: 5, name: "message_encoding", kind: "enum", T: proto2.getEnumType(FeatureSet_MessageEncoding), opt: true },
1426
1511
  { 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
1512
  ]);
1429
1513
  /**
1430
1514
  * @generated from enum google.protobuf.FeatureSet.FieldPresence
@@ -1504,33 +1588,28 @@ proto2.util.setEnumType(FeatureSet_RepeatedFieldEncoding, "google.protobuf.Featu
1504
1588
  { no: 2, name: "EXPANDED" },
1505
1589
  ]);
1506
1590
  /**
1507
- * @generated from enum google.protobuf.FeatureSet.StringFieldValidation
1591
+ * @generated from enum google.protobuf.FeatureSet.Utf8Validation
1508
1592
  */
1509
- export var FeatureSet_StringFieldValidation;
1510
- (function (FeatureSet_StringFieldValidation) {
1593
+ export var FeatureSet_Utf8Validation;
1594
+ (function (FeatureSet_Utf8Validation) {
1511
1595
  /**
1512
- * @generated from enum value: STRING_FIELD_VALIDATION_UNKNOWN = 0;
1596
+ * @generated from enum value: UTF8_VALIDATION_UNKNOWN = 0;
1513
1597
  */
1514
- FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["STRING_FIELD_VALIDATION_UNKNOWN"] = 0] = "STRING_FIELD_VALIDATION_UNKNOWN";
1598
+ FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["UTF8_VALIDATION_UNKNOWN"] = 0] = "UTF8_VALIDATION_UNKNOWN";
1515
1599
  /**
1516
- * @generated from enum value: MANDATORY = 1;
1600
+ * @generated from enum value: NONE = 1;
1517
1601
  */
1518
- FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["MANDATORY"] = 1] = "MANDATORY";
1602
+ FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["NONE"] = 1] = "NONE";
1519
1603
  /**
1520
- * @generated from enum value: HINT = 2;
1604
+ * @generated from enum value: VERIFY = 2;
1521
1605
  */
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" },
1606
+ FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["VERIFY"] = 2] = "VERIFY";
1607
+ })(FeatureSet_Utf8Validation || (FeatureSet_Utf8Validation = {}));
1608
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_Utf8Validation)
1609
+ proto2.util.setEnumType(FeatureSet_Utf8Validation, "google.protobuf.FeatureSet.Utf8Validation", [
1610
+ { no: 0, name: "UTF8_VALIDATION_UNKNOWN" },
1611
+ { no: 1, name: "NONE" },
1612
+ { no: 2, name: "VERIFY" },
1534
1613
  ]);
1535
1614
  /**
1536
1615
  * @generated from enum google.protobuf.FeatureSet.MessageEncoding
@@ -1580,6 +1659,75 @@ proto2.util.setEnumType(FeatureSet_JsonFormat, "google.protobuf.FeatureSet.JsonF
1580
1659
  { no: 1, name: "ALLOW" },
1581
1660
  { no: 2, name: "LEGACY_BEST_EFFORT" },
1582
1661
  ]);
1662
+ /**
1663
+ * A compiled specification for the defaults of a set of features. These
1664
+ * messages are generated from FeatureSet extensions and can be used to seed
1665
+ * feature resolution. The resolution with this object becomes a simple search
1666
+ * for the closest matching edition, followed by proto merges.
1667
+ *
1668
+ * @generated from message google.protobuf.FeatureSetDefaults
1669
+ */
1670
+ export class FeatureSetDefaults extends Message {
1671
+ constructor(data) {
1672
+ super();
1673
+ /**
1674
+ * @generated from field: repeated google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault defaults = 1;
1675
+ */
1676
+ this.defaults = [];
1677
+ proto2.util.initPartial(data, this);
1678
+ }
1679
+ static fromBinary(bytes, options) {
1680
+ return new FeatureSetDefaults().fromBinary(bytes, options);
1681
+ }
1682
+ static fromJson(jsonValue, options) {
1683
+ return new FeatureSetDefaults().fromJson(jsonValue, options);
1684
+ }
1685
+ static fromJsonString(jsonString, options) {
1686
+ return new FeatureSetDefaults().fromJsonString(jsonString, options);
1687
+ }
1688
+ static equals(a, b) {
1689
+ return proto2.util.equals(FeatureSetDefaults, a, b);
1690
+ }
1691
+ }
1692
+ FeatureSetDefaults.runtime = proto2;
1693
+ FeatureSetDefaults.typeName = "google.protobuf.FeatureSetDefaults";
1694
+ FeatureSetDefaults.fields = proto2.util.newFieldList(() => [
1695
+ { no: 1, name: "defaults", kind: "message", T: FeatureSetDefaults_FeatureSetEditionDefault, repeated: true },
1696
+ { no: 4, name: "minimum_edition", kind: "enum", T: proto2.getEnumType(Edition), opt: true },
1697
+ { no: 5, name: "maximum_edition", kind: "enum", T: proto2.getEnumType(Edition), opt: true },
1698
+ ]);
1699
+ /**
1700
+ * A map from every known edition with a unique set of defaults to its
1701
+ * defaults. Not all editions may be contained here. For a given edition,
1702
+ * the defaults at the closest matching edition ordered at or before it should
1703
+ * be used. This field must be in strict ascending order by edition.
1704
+ *
1705
+ * @generated from message google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault
1706
+ */
1707
+ export class FeatureSetDefaults_FeatureSetEditionDefault extends Message {
1708
+ constructor(data) {
1709
+ super();
1710
+ proto2.util.initPartial(data, this);
1711
+ }
1712
+ static fromBinary(bytes, options) {
1713
+ return new FeatureSetDefaults_FeatureSetEditionDefault().fromBinary(bytes, options);
1714
+ }
1715
+ static fromJson(jsonValue, options) {
1716
+ return new FeatureSetDefaults_FeatureSetEditionDefault().fromJson(jsonValue, options);
1717
+ }
1718
+ static fromJsonString(jsonString, options) {
1719
+ return new FeatureSetDefaults_FeatureSetEditionDefault().fromJsonString(jsonString, options);
1720
+ }
1721
+ static equals(a, b) {
1722
+ return proto2.util.equals(FeatureSetDefaults_FeatureSetEditionDefault, a, b);
1723
+ }
1724
+ }
1725
+ FeatureSetDefaults_FeatureSetEditionDefault.runtime = proto2;
1726
+ FeatureSetDefaults_FeatureSetEditionDefault.typeName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault";
1727
+ FeatureSetDefaults_FeatureSetEditionDefault.fields = proto2.util.newFieldList(() => [
1728
+ { no: 3, name: "edition", kind: "enum", T: proto2.getEnumType(Edition), opt: true },
1729
+ { no: 2, name: "features", kind: "message", T: FeatureSet, opt: true },
1730
+ ]);
1583
1731
  /**
1584
1732
  * Encapsulates information about the original source file from which a
1585
1733
  * FileDescriptorProto was generated.
@@ -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.4.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
14
+ // @generated by protoc-gen-es v1.4.2 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.4.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
14
+ // @generated by protoc-gen-es v1.4.2 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";
@@ -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.
@@ -3,6 +3,19 @@ import type { EnumType } from "./enum.js";
3
3
  import type { ServiceType } from "./service-type.js";
4
4
  /**
5
5
  * IMessageTypeRegistry provides look-up for message types.
6
+ *
7
+ * You can conveniently create a registry using the createRegistry()
8
+ * function:
9
+ *
10
+ * ```ts
11
+ * import { createRegistry } from "@bufbuild/protobuf";
12
+ * import { MyMessage, MyOtherMessage } from "./gen/my_message_pb.js";
13
+ *
14
+ * const reg: IMessageTypeRegistry = createRegistry(
15
+ * MyMessage,
16
+ * MyOtherMessage,
17
+ * );
18
+ * ```
6
19
  */
7
20
  export interface IMessageTypeRegistry {
8
21
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protobuf",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "license": "(Apache-2.0 AND BSD-3-Clause)",
5
5
  "description": "A complete implementation of Protocol Buffers in TypeScript, suitable for web browsers and Node.js.",
6
6
  "repository": {