@bufbuild/protobuf 1.4.1 → 1.5.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.
@@ -13,9 +13,89 @@
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.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
- const message_js_1 = require("../../message.js");
16
+ exports.GeneratedCodeInfo_Annotation_Semantic = exports.GeneratedCodeInfo_Annotation = exports.GeneratedCodeInfo = exports.SourceCodeInfo_Location = exports.SourceCodeInfo = exports.FeatureSetDefaults_FeatureSetEditionDefault = exports.FeatureSetDefaults = exports.FeatureSet_JsonFormat = exports.FeatureSet_MessageEncoding = exports.FeatureSet_Utf8Validation = 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 = exports.Edition = void 0;
17
+ // Author: kenton@google.com (Kenton Varda)
18
+ // Based on original Protocol Buffers design by
19
+ // Sanjay Ghemawat, Jeff Dean, and others.
20
+ //
21
+ // The messages in this file describe the definitions found in .proto files.
22
+ // A valid .proto file can be translated directly to a FileDescriptorProto
23
+ // without any other information (e.g. without reading its imports).
24
+ // @generated by protoc-gen-es v1.5.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
25
+ // @generated from file google/protobuf/descriptor.proto (package google.protobuf, syntax proto2)
26
+ /* eslint-disable */
18
27
  const proto2_js_1 = require("../../proto2.js");
28
+ const message_js_1 = require("../../message.js");
29
+ /**
30
+ * The full set of known editions.
31
+ *
32
+ * @generated from enum google.protobuf.Edition
33
+ */
34
+ var Edition;
35
+ (function (Edition) {
36
+ /**
37
+ * A placeholder for an unknown edition value.
38
+ *
39
+ * @generated from enum value: EDITION_UNKNOWN = 0;
40
+ */
41
+ Edition[Edition["EDITION_UNKNOWN"] = 0] = "EDITION_UNKNOWN";
42
+ /**
43
+ * Legacy syntax "editions". These pre-date editions, but behave much like
44
+ * distinct editions. These can't be used to specify the edition of proto
45
+ * files, but feature definitions must supply proto2/proto3 defaults for
46
+ * backwards compatibility.
47
+ *
48
+ * @generated from enum value: EDITION_PROTO2 = 998;
49
+ */
50
+ Edition[Edition["EDITION_PROTO2"] = 998] = "EDITION_PROTO2";
51
+ /**
52
+ * @generated from enum value: EDITION_PROTO3 = 999;
53
+ */
54
+ Edition[Edition["EDITION_PROTO3"] = 999] = "EDITION_PROTO3";
55
+ /**
56
+ * Editions that have been released. The specific values are arbitrary and
57
+ * should not be depended on, but they will always be time-ordered for easy
58
+ * comparison.
59
+ *
60
+ * @generated from enum value: EDITION_2023 = 1000;
61
+ */
62
+ Edition[Edition["EDITION_2023"] = 1000] = "EDITION_2023";
63
+ /**
64
+ * Placeholder editions for testing feature resolution. These should not be
65
+ * used or relyed on outside of tests.
66
+ *
67
+ * @generated from enum value: EDITION_1_TEST_ONLY = 1;
68
+ */
69
+ Edition[Edition["EDITION_1_TEST_ONLY"] = 1] = "EDITION_1_TEST_ONLY";
70
+ /**
71
+ * @generated from enum value: EDITION_2_TEST_ONLY = 2;
72
+ */
73
+ Edition[Edition["EDITION_2_TEST_ONLY"] = 2] = "EDITION_2_TEST_ONLY";
74
+ /**
75
+ * @generated from enum value: EDITION_99997_TEST_ONLY = 99997;
76
+ */
77
+ Edition[Edition["EDITION_99997_TEST_ONLY"] = 99997] = "EDITION_99997_TEST_ONLY";
78
+ /**
79
+ * @generated from enum value: EDITION_99998_TEST_ONLY = 99998;
80
+ */
81
+ Edition[Edition["EDITION_99998_TEST_ONLY"] = 99998] = "EDITION_99998_TEST_ONLY";
82
+ /**
83
+ * @generated from enum value: EDITION_99999_TEST_ONLY = 99999;
84
+ */
85
+ Edition[Edition["EDITION_99999_TEST_ONLY"] = 99999] = "EDITION_99999_TEST_ONLY";
86
+ })(Edition || (exports.Edition = Edition = {}));
87
+ // Retrieve enum metadata with: proto2.getEnumType(Edition)
88
+ proto2_js_1.proto2.util.setEnumType(Edition, "google.protobuf.Edition", [
89
+ { no: 0, name: "EDITION_UNKNOWN" },
90
+ { no: 998, name: "EDITION_PROTO2" },
91
+ { no: 999, name: "EDITION_PROTO3" },
92
+ { no: 1000, name: "EDITION_2023" },
93
+ { no: 1, name: "EDITION_1_TEST_ONLY" },
94
+ { no: 2, name: "EDITION_2_TEST_ONLY" },
95
+ { no: 99997, name: "EDITION_99997_TEST_ONLY" },
96
+ { no: 99998, name: "EDITION_99998_TEST_ONLY" },
97
+ { no: 99999, name: "EDITION_99999_TEST_ONLY" },
98
+ ]);
19
99
  /**
20
100
  * The protocol compiler can output a FileDescriptorSet containing the .proto
21
101
  * files it parses.
@@ -126,7 +206,7 @@ FileDescriptorProto.fields = proto2_js_1.proto2.util.newFieldList(() => [
126
206
  { no: 8, name: "options", kind: "message", T: FileOptions, opt: true },
127
207
  { no: 9, name: "source_code_info", kind: "message", T: SourceCodeInfo, opt: true },
128
208
  { no: 12, name: "syntax", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
129
- { no: 13, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
209
+ { no: 14, name: "edition", kind: "enum", T: proto2_js_1.proto2.getEnumType(Edition), opt: true },
130
210
  ]);
131
211
  /**
132
212
  * Describes a message type.
@@ -451,9 +531,10 @@ var FieldDescriptorProto_Type;
451
531
  FieldDescriptorProto_Type[FieldDescriptorProto_Type["STRING"] = 9] = "STRING";
452
532
  /**
453
533
  * Tag-delimited aggregate.
454
- * Group type is deprecated and not supported in proto3. However, Proto3
534
+ * Group type is deprecated and not supported after google.protobuf. However, Proto3
455
535
  * implementations should still be able to parse the group wire format and
456
- * treat group fields as unknown fields.
536
+ * treat group fields as unknown fields. In Editions, the group wire format
537
+ * can be enabled via the `message_encoding` feature.
457
538
  *
458
539
  * @generated from enum value: TYPE_GROUP = 10;
459
540
  */
@@ -531,20 +612,24 @@ var FieldDescriptorProto_Label;
531
612
  * @generated from enum value: LABEL_OPTIONAL = 1;
532
613
  */
533
614
  FieldDescriptorProto_Label[FieldDescriptorProto_Label["OPTIONAL"] = 1] = "OPTIONAL";
534
- /**
535
- * @generated from enum value: LABEL_REQUIRED = 2;
536
- */
537
- FieldDescriptorProto_Label[FieldDescriptorProto_Label["REQUIRED"] = 2] = "REQUIRED";
538
615
  /**
539
616
  * @generated from enum value: LABEL_REPEATED = 3;
540
617
  */
541
618
  FieldDescriptorProto_Label[FieldDescriptorProto_Label["REPEATED"] = 3] = "REPEATED";
619
+ /**
620
+ * The required label is only allowed in google.protobuf. In proto3 and Editions
621
+ * it's explicitly prohibited. In Editions, the `field_presence` feature
622
+ * can be used to get this behavior.
623
+ *
624
+ * @generated from enum value: LABEL_REQUIRED = 2;
625
+ */
626
+ FieldDescriptorProto_Label[FieldDescriptorProto_Label["REQUIRED"] = 2] = "REQUIRED";
542
627
  })(FieldDescriptorProto_Label || (exports.FieldDescriptorProto_Label = FieldDescriptorProto_Label = {}));
543
628
  // Retrieve enum metadata with: proto2.getEnumType(FieldDescriptorProto_Label)
544
629
  proto2_js_1.proto2.util.setEnumType(FieldDescriptorProto_Label, "google.protobuf.FieldDescriptorProto.Label", [
545
630
  { no: 1, name: "LABEL_OPTIONAL" },
546
- { no: 2, name: "LABEL_REQUIRED" },
547
631
  { no: 3, name: "LABEL_REPEATED" },
632
+ { no: 2, name: "LABEL_REQUIRED" },
548
633
  ]);
549
634
  /**
550
635
  * Describes a oneof.
@@ -1124,7 +1209,7 @@ exports.FieldOptions_EditionDefault = FieldOptions_EditionDefault;
1124
1209
  FieldOptions_EditionDefault.runtime = proto2_js_1.proto2;
1125
1210
  FieldOptions_EditionDefault.typeName = "google.protobuf.FieldOptions.EditionDefault";
1126
1211
  FieldOptions_EditionDefault.fields = proto2_js_1.proto2.util.newFieldList(() => [
1127
- { no: 1, name: "edition", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
1212
+ { no: 3, name: "edition", kind: "enum", T: proto2_js_1.proto2.getEnumType(Edition), opt: true },
1128
1213
  { no: 2, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
1129
1214
  ]);
1130
1215
  /**
@@ -1416,7 +1501,7 @@ UninterpretedOption_NamePart.fields = proto2_js_1.proto2.util.newFieldList(() =>
1416
1501
  { no: 2, name: "is_extension", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
1417
1502
  ]);
1418
1503
  /**
1419
- * TODO(b/274655146) Enums in C++ gencode (and potentially other languages) are
1504
+ * TODO Enums in C++ gencode (and potentially other languages) are
1420
1505
  * not well scoped. This means that each of the feature enums below can clash
1421
1506
  * with each other. The short names we've chosen maximize call-site
1422
1507
  * readability, but leave us very open to this scenario. A future feature will
@@ -1450,10 +1535,9 @@ FeatureSet.fields = proto2_js_1.proto2.util.newFieldList(() => [
1450
1535
  { no: 1, name: "field_presence", kind: "enum", T: proto2_js_1.proto2.getEnumType(FeatureSet_FieldPresence), opt: true },
1451
1536
  { no: 2, name: "enum_type", kind: "enum", T: proto2_js_1.proto2.getEnumType(FeatureSet_EnumType), opt: true },
1452
1537
  { 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 },
1538
+ { no: 4, name: "utf8_validation", kind: "enum", T: proto2_js_1.proto2.getEnumType(FeatureSet_Utf8Validation), opt: true },
1454
1539
  { no: 5, name: "message_encoding", kind: "enum", T: proto2_js_1.proto2.getEnumType(FeatureSet_MessageEncoding), opt: true },
1455
1540
  { 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
1541
  ]);
1458
1542
  /**
1459
1543
  * @generated from enum google.protobuf.FeatureSet.FieldPresence
@@ -1533,33 +1617,28 @@ proto2_js_1.proto2.util.setEnumType(FeatureSet_RepeatedFieldEncoding, "google.pr
1533
1617
  { no: 2, name: "EXPANDED" },
1534
1618
  ]);
1535
1619
  /**
1536
- * @generated from enum google.protobuf.FeatureSet.StringFieldValidation
1620
+ * @generated from enum google.protobuf.FeatureSet.Utf8Validation
1537
1621
  */
1538
- var FeatureSet_StringFieldValidation;
1539
- (function (FeatureSet_StringFieldValidation) {
1622
+ var FeatureSet_Utf8Validation;
1623
+ (function (FeatureSet_Utf8Validation) {
1540
1624
  /**
1541
- * @generated from enum value: STRING_FIELD_VALIDATION_UNKNOWN = 0;
1625
+ * @generated from enum value: UTF8_VALIDATION_UNKNOWN = 0;
1542
1626
  */
1543
- FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["STRING_FIELD_VALIDATION_UNKNOWN"] = 0] = "STRING_FIELD_VALIDATION_UNKNOWN";
1627
+ FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["UTF8_VALIDATION_UNKNOWN"] = 0] = "UTF8_VALIDATION_UNKNOWN";
1544
1628
  /**
1545
- * @generated from enum value: MANDATORY = 1;
1629
+ * @generated from enum value: NONE = 1;
1546
1630
  */
1547
- FeatureSet_StringFieldValidation[FeatureSet_StringFieldValidation["MANDATORY"] = 1] = "MANDATORY";
1631
+ FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["NONE"] = 1] = "NONE";
1548
1632
  /**
1549
- * @generated from enum value: HINT = 2;
1633
+ * @generated from enum value: VERIFY = 2;
1550
1634
  */
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" },
1635
+ FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["VERIFY"] = 2] = "VERIFY";
1636
+ })(FeatureSet_Utf8Validation || (exports.FeatureSet_Utf8Validation = FeatureSet_Utf8Validation = {}));
1637
+ // Retrieve enum metadata with: proto2.getEnumType(FeatureSet_Utf8Validation)
1638
+ proto2_js_1.proto2.util.setEnumType(FeatureSet_Utf8Validation, "google.protobuf.FeatureSet.Utf8Validation", [
1639
+ { no: 0, name: "UTF8_VALIDATION_UNKNOWN" },
1640
+ { no: 1, name: "NONE" },
1641
+ { no: 2, name: "VERIFY" },
1563
1642
  ]);
1564
1643
  /**
1565
1644
  * @generated from enum google.protobuf.FeatureSet.MessageEncoding
@@ -1609,6 +1688,77 @@ proto2_js_1.proto2.util.setEnumType(FeatureSet_JsonFormat, "google.protobuf.Feat
1609
1688
  { no: 1, name: "ALLOW" },
1610
1689
  { no: 2, name: "LEGACY_BEST_EFFORT" },
1611
1690
  ]);
1691
+ /**
1692
+ * A compiled specification for the defaults of a set of features. These
1693
+ * messages are generated from FeatureSet extensions and can be used to seed
1694
+ * feature resolution. The resolution with this object becomes a simple search
1695
+ * for the closest matching edition, followed by proto merges.
1696
+ *
1697
+ * @generated from message google.protobuf.FeatureSetDefaults
1698
+ */
1699
+ class FeatureSetDefaults extends message_js_1.Message {
1700
+ constructor(data) {
1701
+ super();
1702
+ /**
1703
+ * @generated from field: repeated google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault defaults = 1;
1704
+ */
1705
+ this.defaults = [];
1706
+ proto2_js_1.proto2.util.initPartial(data, this);
1707
+ }
1708
+ static fromBinary(bytes, options) {
1709
+ return new FeatureSetDefaults().fromBinary(bytes, options);
1710
+ }
1711
+ static fromJson(jsonValue, options) {
1712
+ return new FeatureSetDefaults().fromJson(jsonValue, options);
1713
+ }
1714
+ static fromJsonString(jsonString, options) {
1715
+ return new FeatureSetDefaults().fromJsonString(jsonString, options);
1716
+ }
1717
+ static equals(a, b) {
1718
+ return proto2_js_1.proto2.util.equals(FeatureSetDefaults, a, b);
1719
+ }
1720
+ }
1721
+ exports.FeatureSetDefaults = FeatureSetDefaults;
1722
+ FeatureSetDefaults.runtime = proto2_js_1.proto2;
1723
+ FeatureSetDefaults.typeName = "google.protobuf.FeatureSetDefaults";
1724
+ FeatureSetDefaults.fields = proto2_js_1.proto2.util.newFieldList(() => [
1725
+ { no: 1, name: "defaults", kind: "message", T: FeatureSetDefaults_FeatureSetEditionDefault, repeated: true },
1726
+ { no: 4, name: "minimum_edition", kind: "enum", T: proto2_js_1.proto2.getEnumType(Edition), opt: true },
1727
+ { no: 5, name: "maximum_edition", kind: "enum", T: proto2_js_1.proto2.getEnumType(Edition), opt: true },
1728
+ ]);
1729
+ /**
1730
+ * A map from every known edition with a unique set of defaults to its
1731
+ * defaults. Not all editions may be contained here. For a given edition,
1732
+ * the defaults at the closest matching edition ordered at or before it should
1733
+ * be used. This field must be in strict ascending order by edition.
1734
+ *
1735
+ * @generated from message google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault
1736
+ */
1737
+ class FeatureSetDefaults_FeatureSetEditionDefault extends message_js_1.Message {
1738
+ constructor(data) {
1739
+ super();
1740
+ proto2_js_1.proto2.util.initPartial(data, this);
1741
+ }
1742
+ static fromBinary(bytes, options) {
1743
+ return new FeatureSetDefaults_FeatureSetEditionDefault().fromBinary(bytes, options);
1744
+ }
1745
+ static fromJson(jsonValue, options) {
1746
+ return new FeatureSetDefaults_FeatureSetEditionDefault().fromJson(jsonValue, options);
1747
+ }
1748
+ static fromJsonString(jsonString, options) {
1749
+ return new FeatureSetDefaults_FeatureSetEditionDefault().fromJsonString(jsonString, options);
1750
+ }
1751
+ static equals(a, b) {
1752
+ return proto2_js_1.proto2.util.equals(FeatureSetDefaults_FeatureSetEditionDefault, a, b);
1753
+ }
1754
+ }
1755
+ exports.FeatureSetDefaults_FeatureSetEditionDefault = FeatureSetDefaults_FeatureSetEditionDefault;
1756
+ FeatureSetDefaults_FeatureSetEditionDefault.runtime = proto2_js_1.proto2;
1757
+ FeatureSetDefaults_FeatureSetEditionDefault.typeName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault";
1758
+ FeatureSetDefaults_FeatureSetEditionDefault.fields = proto2_js_1.proto2.util.newFieldList(() => [
1759
+ { no: 3, name: "edition", kind: "enum", T: proto2_js_1.proto2.getEnumType(Edition), opt: true },
1760
+ { no: 2, name: "features", kind: "message", T: FeatureSet, opt: true },
1761
+ ]);
1612
1762
  /**
1613
1763
  * Encapsulates information about the original source file from which a
1614
1764
  * FileDescriptorProto was generated.
@@ -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.4.1 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
17
+ // @generated by protoc-gen-es v1.5.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.4.1 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
17
+ // @generated by protoc-gen-es v1.5.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");
@@ -0,0 +1,21 @@
1
+ import { Edition, FeatureSet, FeatureSetDefaults } from "../google/protobuf/descriptor_pb.js";
2
+ /**
3
+ * Static edition feature defaults supported by @bufbuild/protobuf.
4
+ */
5
+ export declare const featureSetDefaults: FeatureSetDefaults;
6
+ /**
7
+ * A merged google.protobuf.FeaturesSet, with all fields guaranteed to be set.
8
+ */
9
+ export type MergedFeatureSet = FeatureSet & Required<FeatureSet>;
10
+ /**
11
+ * A function that resolves features for the given edition.
12
+ *
13
+ * If no feature set is provided, the default feature set for the edition is
14
+ * returned. If features are provided, they are merged into the edition default
15
+ * features.
16
+ */
17
+ export type FeatureResolverFn = (edition: Edition, a?: FeatureSet, b?: FeatureSet) => MergedFeatureSet;
18
+ /**
19
+ * Create an edition feature resolver with the given feature set defaults.
20
+ */
21
+ export declare function createFeatureResolver(compiledFeatureSetDefaults: FeatureSetDefaults): FeatureResolverFn;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ // Copyright 2021-2023 Buf Technologies, Inc.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.createFeatureResolver = exports.featureSetDefaults = void 0;
17
+ const descriptor_pb_js_1 = require("../google/protobuf/descriptor_pb.js");
18
+ const proto_base64_js_1 = require("../proto-base64.js");
19
+ /**
20
+ * Static edition feature defaults supported by @bufbuild/protobuf.
21
+ */
22
+ exports.featureSetDefaults = descriptor_pb_js_1.FeatureSetDefaults.fromBinary(proto_base64_js_1.protoBase64.dec(
23
+ /*upstream-inject-feature-defaults-start*/ "ChESDAgBEAIYAiABKAEwAhjmBwoREgwIAhABGAEgAigBMAEY5wcKERIMCAEQARgBIAIoATABGOgHIOYHKOgH" /*upstream-inject-feature-defaults-end*/));
24
+ /**
25
+ * Create an edition feature resolver with the given feature set defaults.
26
+ */
27
+ function createFeatureResolver(compiledFeatureSetDefaults) {
28
+ const min = compiledFeatureSetDefaults.minimumEdition;
29
+ const max = compiledFeatureSetDefaults.maximumEdition;
30
+ if (min === undefined ||
31
+ max === undefined ||
32
+ compiledFeatureSetDefaults.defaults.some((d) => d.edition === undefined)) {
33
+ throw new Error("Invalid FeatureSetDefaults");
34
+ }
35
+ const defaultsBinByEdition = new Map();
36
+ return (edition, ...rest) => {
37
+ var _a, _b;
38
+ let defaultsBin = defaultsBinByEdition.get(edition);
39
+ if (defaultsBin === undefined) {
40
+ if (edition < min) {
41
+ throw new Error(`Edition ${descriptor_pb_js_1.Edition[edition]} is earlier than the minimum supported edition ${descriptor_pb_js_1.Edition[min]}`);
42
+ }
43
+ if (max < edition) {
44
+ throw new Error(`Edition ${descriptor_pb_js_1.Edition[edition]} is later than the maximum supported edition ${descriptor_pb_js_1.Edition[max]}`);
45
+ }
46
+ let highestMatch = undefined;
47
+ for (const c of compiledFeatureSetDefaults.defaults) {
48
+ const e = (_a = c.edition) !== null && _a !== void 0 ? _a : 0;
49
+ if (e > edition) {
50
+ continue;
51
+ }
52
+ if (highestMatch !== undefined && highestMatch.e > e) {
53
+ continue;
54
+ }
55
+ highestMatch = {
56
+ e,
57
+ f: (_b = c.features) !== null && _b !== void 0 ? _b : new descriptor_pb_js_1.FeatureSet(),
58
+ };
59
+ }
60
+ if (highestMatch === undefined) {
61
+ throw new Error(`No valid default found for edition ${descriptor_pb_js_1.Edition[edition]}`);
62
+ }
63
+ defaultsBin = highestMatch.f.toBinary();
64
+ defaultsBinByEdition.set(edition, defaultsBin);
65
+ }
66
+ const f = descriptor_pb_js_1.FeatureSet.fromBinary(defaultsBin);
67
+ for (const c of rest) {
68
+ if (c !== undefined) {
69
+ f.fromBinary(c.toBinary());
70
+ }
71
+ }
72
+ if (!validateMergedFeatures(f)) {
73
+ throw new Error(`Invalid FeatureSet for edition ${descriptor_pb_js_1.Edition[edition]}`);
74
+ }
75
+ return f;
76
+ };
77
+ }
78
+ exports.createFeatureResolver = createFeatureResolver;
79
+ // When protoc generates google.protobuf.FeatureSetDefaults, it ensures that
80
+ // fields are not repeated or required, do not use oneof, and have a default
81
+ // value.
82
+ //
83
+ // When features for an element are resolved, features of the element and its
84
+ // parents are merged into the default FeatureSet for the edition. Because unset
85
+ // fields in the FeatureSet of an element do not unset the default FeatureSet
86
+ // values, a resolved FeatureSet is guaranteed to have all fields set. This is
87
+ // also the case for extensions to FeatureSet that a user might provide, and for
88
+ // features from the future.
89
+ //
90
+ // We cannot exhaustively validate correctness of FeatureSetDefaults at runtime
91
+ // without knowing the schema: If no value for a feature is provided, we do not
92
+ // know that it exists at all.
93
+ //
94
+ // As a sanity check, we validate that all fields known to our version of
95
+ // FeatureSet are set.
96
+ function validateMergedFeatures(featureSet) {
97
+ for (const fi of descriptor_pb_js_1.FeatureSet.fields.list()) {
98
+ const v = featureSet[fi.localName];
99
+ if (v === undefined) {
100
+ return false;
101
+ }
102
+ if (fi.kind == "enum" && v === 0) {
103
+ return false;
104
+ }
105
+ }
106
+ return true;
107
+ }
@@ -0,0 +1,4 @@
1
+ import type { DescEnum } from "../descriptor-set.js";
2
+ import { ScalarType } from "../field.js";
3
+ export declare function parseTextFormatEnumValue(descEnum: DescEnum, value: string): number;
4
+ export declare function parseTextFormatScalarValue(type: ScalarType, value: string): number | boolean | string | bigint | Uint8Array;
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ // Copyright 2021-2023 Buf Technologies, Inc.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.parseTextFormatScalarValue = exports.parseTextFormatEnumValue = void 0;
17
+ const assert_js_1 = require("./assert.js");
18
+ const field_js_1 = require("../field.js");
19
+ const proto_int64_js_1 = require("../proto-int64.js");
20
+ function parseTextFormatEnumValue(descEnum, value) {
21
+ const enumValue = descEnum.values.find((v) => v.name === value);
22
+ (0, assert_js_1.assert)(enumValue, `cannot parse ${descEnum.name} default value: ${value}`);
23
+ return enumValue.number;
24
+ }
25
+ exports.parseTextFormatEnumValue = parseTextFormatEnumValue;
26
+ function parseTextFormatScalarValue(type, value) {
27
+ switch (type) {
28
+ case field_js_1.ScalarType.STRING:
29
+ return value;
30
+ case field_js_1.ScalarType.BYTES: {
31
+ const u = unescapeBytesDefaultValue(value);
32
+ if (u === false) {
33
+ throw new Error(`cannot parse ${field_js_1.ScalarType[type]} default value: ${value}`);
34
+ }
35
+ return u;
36
+ }
37
+ case field_js_1.ScalarType.INT64:
38
+ case field_js_1.ScalarType.SFIXED64:
39
+ case field_js_1.ScalarType.SINT64:
40
+ return proto_int64_js_1.protoInt64.parse(value);
41
+ case field_js_1.ScalarType.UINT64:
42
+ case field_js_1.ScalarType.FIXED64:
43
+ return proto_int64_js_1.protoInt64.uParse(value);
44
+ case field_js_1.ScalarType.DOUBLE:
45
+ case field_js_1.ScalarType.FLOAT:
46
+ switch (value) {
47
+ case "inf":
48
+ return Number.POSITIVE_INFINITY;
49
+ case "-inf":
50
+ return Number.NEGATIVE_INFINITY;
51
+ case "nan":
52
+ return Number.NaN;
53
+ default:
54
+ return parseFloat(value);
55
+ }
56
+ case field_js_1.ScalarType.BOOL:
57
+ return value === "true";
58
+ case field_js_1.ScalarType.INT32:
59
+ case field_js_1.ScalarType.UINT32:
60
+ case field_js_1.ScalarType.SINT32:
61
+ case field_js_1.ScalarType.FIXED32:
62
+ case field_js_1.ScalarType.SFIXED32:
63
+ return parseInt(value, 10);
64
+ }
65
+ }
66
+ exports.parseTextFormatScalarValue = parseTextFormatScalarValue;
67
+ /**
68
+ * Parses a text-encoded default value (proto2) of a BYTES field.
69
+ */
70
+ function unescapeBytesDefaultValue(str) {
71
+ const b = [];
72
+ const input = {
73
+ tail: str,
74
+ c: "",
75
+ next() {
76
+ if (this.tail.length == 0) {
77
+ return false;
78
+ }
79
+ this.c = this.tail[0];
80
+ this.tail = this.tail.substring(1);
81
+ return true;
82
+ },
83
+ take(n) {
84
+ if (this.tail.length >= n) {
85
+ const r = this.tail.substring(0, n);
86
+ this.tail = this.tail.substring(n);
87
+ return r;
88
+ }
89
+ return false;
90
+ },
91
+ };
92
+ while (input.next()) {
93
+ switch (input.c) {
94
+ case "\\":
95
+ if (input.next()) {
96
+ switch (input.c) {
97
+ case "\\":
98
+ b.push(input.c.charCodeAt(0));
99
+ break;
100
+ case "b":
101
+ b.push(0x08);
102
+ break;
103
+ case "f":
104
+ b.push(0x0c);
105
+ break;
106
+ case "n":
107
+ b.push(0x0a);
108
+ break;
109
+ case "r":
110
+ b.push(0x0d);
111
+ break;
112
+ case "t":
113
+ b.push(0x09);
114
+ break;
115
+ case "v":
116
+ b.push(0x0b);
117
+ break;
118
+ case "0":
119
+ case "1":
120
+ case "2":
121
+ case "3":
122
+ case "4":
123
+ case "5":
124
+ case "6":
125
+ case "7": {
126
+ const s = input.c;
127
+ const t = input.take(2);
128
+ if (t === false) {
129
+ return false;
130
+ }
131
+ const n = parseInt(s + t, 8);
132
+ if (isNaN(n)) {
133
+ return false;
134
+ }
135
+ b.push(n);
136
+ break;
137
+ }
138
+ case "x": {
139
+ const s = input.c;
140
+ const t = input.take(2);
141
+ if (t === false) {
142
+ return false;
143
+ }
144
+ const n = parseInt(s + t, 16);
145
+ if (isNaN(n)) {
146
+ return false;
147
+ }
148
+ b.push(n);
149
+ break;
150
+ }
151
+ case "u": {
152
+ const s = input.c;
153
+ const t = input.take(4);
154
+ if (t === false) {
155
+ return false;
156
+ }
157
+ const n = parseInt(s + t, 16);
158
+ if (isNaN(n)) {
159
+ return false;
160
+ }
161
+ const chunk = new Uint8Array(4);
162
+ const view = new DataView(chunk.buffer);
163
+ view.setInt32(0, n, true);
164
+ b.push(chunk[0], chunk[1], chunk[2], chunk[3]);
165
+ break;
166
+ }
167
+ case "U": {
168
+ const s = input.c;
169
+ const t = input.take(8);
170
+ if (t === false) {
171
+ return false;
172
+ }
173
+ const tc = proto_int64_js_1.protoInt64.uEnc(s + t);
174
+ const chunk = new Uint8Array(8);
175
+ const view = new DataView(chunk.buffer);
176
+ view.setInt32(0, tc.lo, true);
177
+ view.setInt32(4, tc.hi, true);
178
+ b.push(chunk[0], chunk[1], chunk[2], chunk[3], chunk[4], chunk[5], chunk[6], chunk[7]);
179
+ break;
180
+ }
181
+ }
182
+ }
183
+ break;
184
+ default:
185
+ b.push(input.c.charCodeAt(0));
186
+ }
187
+ }
188
+ return new Uint8Array(b);
189
+ }