@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.
- package/dist/cjs/create-descriptor-set.d.ts +19 -5
- package/dist/cjs/create-descriptor-set.js +157 -223
- package/dist/cjs/descriptor-set.d.ts +47 -5
- package/dist/cjs/google/protobuf/any_pb.js +1 -1
- package/dist/cjs/google/protobuf/descriptor_pb.d.ts +153 -35
- package/dist/cjs/google/protobuf/descriptor_pb.js +184 -34
- package/dist/cjs/google/protobuf/struct_pb.js +1 -1
- package/dist/cjs/google/protobuf/type_pb.js +1 -1
- package/dist/cjs/private/feature-set.d.ts +21 -0
- package/dist/cjs/private/feature-set.js +107 -0
- package/dist/cjs/private/text-format.d.ts +4 -0
- package/dist/cjs/private/text-format.js +189 -0
- package/dist/esm/create-descriptor-set.d.ts +19 -5
- package/dist/esm/create-descriptor-set.js +157 -222
- package/dist/esm/descriptor-set.d.ts +47 -5
- package/dist/esm/google/protobuf/any_pb.js +1 -1
- package/dist/esm/google/protobuf/descriptor_pb.d.ts +153 -35
- package/dist/esm/google/protobuf/descriptor_pb.js +181 -33
- package/dist/esm/google/protobuf/struct_pb.js +1 -1
- package/dist/esm/google/protobuf/type_pb.js +1 -1
- package/dist/esm/private/feature-set.d.ts +21 -0
- package/dist/esm/private/feature-set.js +103 -0
- package/dist/esm/private/text-format.d.ts +4 -0
- package/dist/esm/private/text-format.js +184 -0
- package/package.json +5 -5
|
@@ -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
|
-
|
|
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.5.0 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:
|
|
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
|
|
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:
|
|
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
|
|
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: "
|
|
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.
|
|
1591
|
+
* @generated from enum google.protobuf.FeatureSet.Utf8Validation
|
|
1508
1592
|
*/
|
|
1509
|
-
export var
|
|
1510
|
-
(function (
|
|
1593
|
+
export var FeatureSet_Utf8Validation;
|
|
1594
|
+
(function (FeatureSet_Utf8Validation) {
|
|
1511
1595
|
/**
|
|
1512
|
-
* @generated from enum value:
|
|
1596
|
+
* @generated from enum value: UTF8_VALIDATION_UNKNOWN = 0;
|
|
1513
1597
|
*/
|
|
1514
|
-
|
|
1598
|
+
FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["UTF8_VALIDATION_UNKNOWN"] = 0] = "UTF8_VALIDATION_UNKNOWN";
|
|
1515
1599
|
/**
|
|
1516
|
-
* @generated from enum value:
|
|
1600
|
+
* @generated from enum value: NONE = 1;
|
|
1517
1601
|
*/
|
|
1518
|
-
|
|
1602
|
+
FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["NONE"] = 1] = "NONE";
|
|
1519
1603
|
/**
|
|
1520
|
-
* @generated from enum value:
|
|
1604
|
+
* @generated from enum value: VERIFY = 2;
|
|
1521
1605
|
*/
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
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.
|
|
14
|
+
// @generated by protoc-gen-es v1.5.0 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.
|
|
14
|
+
// @generated by protoc-gen-es v1.5.0 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";
|
|
@@ -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,103 @@
|
|
|
1
|
+
// Copyright 2021-2023 Buf Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { Edition, FeatureSet, FeatureSetDefaults, } from "../google/protobuf/descriptor_pb.js";
|
|
15
|
+
import { protoBase64 } from "../proto-base64.js";
|
|
16
|
+
/**
|
|
17
|
+
* Static edition feature defaults supported by @bufbuild/protobuf.
|
|
18
|
+
*/
|
|
19
|
+
export const featureSetDefaults = FeatureSetDefaults.fromBinary(protoBase64.dec(
|
|
20
|
+
/*upstream-inject-feature-defaults-start*/ "ChESDAgBEAIYAiABKAEwAhjmBwoREgwIAhABGAEgAigBMAEY5wcKERIMCAEQARgBIAIoATABGOgHIOYHKOgH" /*upstream-inject-feature-defaults-end*/));
|
|
21
|
+
/**
|
|
22
|
+
* Create an edition feature resolver with the given feature set defaults.
|
|
23
|
+
*/
|
|
24
|
+
export function createFeatureResolver(compiledFeatureSetDefaults) {
|
|
25
|
+
const min = compiledFeatureSetDefaults.minimumEdition;
|
|
26
|
+
const max = compiledFeatureSetDefaults.maximumEdition;
|
|
27
|
+
if (min === undefined ||
|
|
28
|
+
max === undefined ||
|
|
29
|
+
compiledFeatureSetDefaults.defaults.some((d) => d.edition === undefined)) {
|
|
30
|
+
throw new Error("Invalid FeatureSetDefaults");
|
|
31
|
+
}
|
|
32
|
+
const defaultsBinByEdition = new Map();
|
|
33
|
+
return (edition, ...rest) => {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
let defaultsBin = defaultsBinByEdition.get(edition);
|
|
36
|
+
if (defaultsBin === undefined) {
|
|
37
|
+
if (edition < min) {
|
|
38
|
+
throw new Error(`Edition ${Edition[edition]} is earlier than the minimum supported edition ${Edition[min]}`);
|
|
39
|
+
}
|
|
40
|
+
if (max < edition) {
|
|
41
|
+
throw new Error(`Edition ${Edition[edition]} is later than the maximum supported edition ${Edition[max]}`);
|
|
42
|
+
}
|
|
43
|
+
let highestMatch = undefined;
|
|
44
|
+
for (const c of compiledFeatureSetDefaults.defaults) {
|
|
45
|
+
const e = (_a = c.edition) !== null && _a !== void 0 ? _a : 0;
|
|
46
|
+
if (e > edition) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (highestMatch !== undefined && highestMatch.e > e) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
highestMatch = {
|
|
53
|
+
e,
|
|
54
|
+
f: (_b = c.features) !== null && _b !== void 0 ? _b : new FeatureSet(),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (highestMatch === undefined) {
|
|
58
|
+
throw new Error(`No valid default found for edition ${Edition[edition]}`);
|
|
59
|
+
}
|
|
60
|
+
defaultsBin = highestMatch.f.toBinary();
|
|
61
|
+
defaultsBinByEdition.set(edition, defaultsBin);
|
|
62
|
+
}
|
|
63
|
+
const f = FeatureSet.fromBinary(defaultsBin);
|
|
64
|
+
for (const c of rest) {
|
|
65
|
+
if (c !== undefined) {
|
|
66
|
+
f.fromBinary(c.toBinary());
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!validateMergedFeatures(f)) {
|
|
70
|
+
throw new Error(`Invalid FeatureSet for edition ${Edition[edition]}`);
|
|
71
|
+
}
|
|
72
|
+
return f;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// When protoc generates google.protobuf.FeatureSetDefaults, it ensures that
|
|
76
|
+
// fields are not repeated or required, do not use oneof, and have a default
|
|
77
|
+
// value.
|
|
78
|
+
//
|
|
79
|
+
// When features for an element are resolved, features of the element and its
|
|
80
|
+
// parents are merged into the default FeatureSet for the edition. Because unset
|
|
81
|
+
// fields in the FeatureSet of an element do not unset the default FeatureSet
|
|
82
|
+
// values, a resolved FeatureSet is guaranteed to have all fields set. This is
|
|
83
|
+
// also the case for extensions to FeatureSet that a user might provide, and for
|
|
84
|
+
// features from the future.
|
|
85
|
+
//
|
|
86
|
+
// We cannot exhaustively validate correctness of FeatureSetDefaults at runtime
|
|
87
|
+
// without knowing the schema: If no value for a feature is provided, we do not
|
|
88
|
+
// know that it exists at all.
|
|
89
|
+
//
|
|
90
|
+
// As a sanity check, we validate that all fields known to our version of
|
|
91
|
+
// FeatureSet are set.
|
|
92
|
+
function validateMergedFeatures(featureSet) {
|
|
93
|
+
for (const fi of FeatureSet.fields.list()) {
|
|
94
|
+
const v = featureSet[fi.localName];
|
|
95
|
+
if (v === undefined) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (fi.kind == "enum" && v === 0) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
@@ -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,184 @@
|
|
|
1
|
+
// Copyright 2021-2023 Buf Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { assert } from "./assert.js";
|
|
15
|
+
import { ScalarType } from "../field.js";
|
|
16
|
+
import { protoInt64 } from "../proto-int64.js";
|
|
17
|
+
export function parseTextFormatEnumValue(descEnum, value) {
|
|
18
|
+
const enumValue = descEnum.values.find((v) => v.name === value);
|
|
19
|
+
assert(enumValue, `cannot parse ${descEnum.name} default value: ${value}`);
|
|
20
|
+
return enumValue.number;
|
|
21
|
+
}
|
|
22
|
+
export function parseTextFormatScalarValue(type, value) {
|
|
23
|
+
switch (type) {
|
|
24
|
+
case ScalarType.STRING:
|
|
25
|
+
return value;
|
|
26
|
+
case ScalarType.BYTES: {
|
|
27
|
+
const u = unescapeBytesDefaultValue(value);
|
|
28
|
+
if (u === false) {
|
|
29
|
+
throw new Error(`cannot parse ${ScalarType[type]} default value: ${value}`);
|
|
30
|
+
}
|
|
31
|
+
return u;
|
|
32
|
+
}
|
|
33
|
+
case ScalarType.INT64:
|
|
34
|
+
case ScalarType.SFIXED64:
|
|
35
|
+
case ScalarType.SINT64:
|
|
36
|
+
return protoInt64.parse(value);
|
|
37
|
+
case ScalarType.UINT64:
|
|
38
|
+
case ScalarType.FIXED64:
|
|
39
|
+
return protoInt64.uParse(value);
|
|
40
|
+
case ScalarType.DOUBLE:
|
|
41
|
+
case ScalarType.FLOAT:
|
|
42
|
+
switch (value) {
|
|
43
|
+
case "inf":
|
|
44
|
+
return Number.POSITIVE_INFINITY;
|
|
45
|
+
case "-inf":
|
|
46
|
+
return Number.NEGATIVE_INFINITY;
|
|
47
|
+
case "nan":
|
|
48
|
+
return Number.NaN;
|
|
49
|
+
default:
|
|
50
|
+
return parseFloat(value);
|
|
51
|
+
}
|
|
52
|
+
case ScalarType.BOOL:
|
|
53
|
+
return value === "true";
|
|
54
|
+
case ScalarType.INT32:
|
|
55
|
+
case ScalarType.UINT32:
|
|
56
|
+
case ScalarType.SINT32:
|
|
57
|
+
case ScalarType.FIXED32:
|
|
58
|
+
case ScalarType.SFIXED32:
|
|
59
|
+
return parseInt(value, 10);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parses a text-encoded default value (proto2) of a BYTES field.
|
|
64
|
+
*/
|
|
65
|
+
function unescapeBytesDefaultValue(str) {
|
|
66
|
+
const b = [];
|
|
67
|
+
const input = {
|
|
68
|
+
tail: str,
|
|
69
|
+
c: "",
|
|
70
|
+
next() {
|
|
71
|
+
if (this.tail.length == 0) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
this.c = this.tail[0];
|
|
75
|
+
this.tail = this.tail.substring(1);
|
|
76
|
+
return true;
|
|
77
|
+
},
|
|
78
|
+
take(n) {
|
|
79
|
+
if (this.tail.length >= n) {
|
|
80
|
+
const r = this.tail.substring(0, n);
|
|
81
|
+
this.tail = this.tail.substring(n);
|
|
82
|
+
return r;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
while (input.next()) {
|
|
88
|
+
switch (input.c) {
|
|
89
|
+
case "\\":
|
|
90
|
+
if (input.next()) {
|
|
91
|
+
switch (input.c) {
|
|
92
|
+
case "\\":
|
|
93
|
+
b.push(input.c.charCodeAt(0));
|
|
94
|
+
break;
|
|
95
|
+
case "b":
|
|
96
|
+
b.push(0x08);
|
|
97
|
+
break;
|
|
98
|
+
case "f":
|
|
99
|
+
b.push(0x0c);
|
|
100
|
+
break;
|
|
101
|
+
case "n":
|
|
102
|
+
b.push(0x0a);
|
|
103
|
+
break;
|
|
104
|
+
case "r":
|
|
105
|
+
b.push(0x0d);
|
|
106
|
+
break;
|
|
107
|
+
case "t":
|
|
108
|
+
b.push(0x09);
|
|
109
|
+
break;
|
|
110
|
+
case "v":
|
|
111
|
+
b.push(0x0b);
|
|
112
|
+
break;
|
|
113
|
+
case "0":
|
|
114
|
+
case "1":
|
|
115
|
+
case "2":
|
|
116
|
+
case "3":
|
|
117
|
+
case "4":
|
|
118
|
+
case "5":
|
|
119
|
+
case "6":
|
|
120
|
+
case "7": {
|
|
121
|
+
const s = input.c;
|
|
122
|
+
const t = input.take(2);
|
|
123
|
+
if (t === false) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const n = parseInt(s + t, 8);
|
|
127
|
+
if (isNaN(n)) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
b.push(n);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case "x": {
|
|
134
|
+
const s = input.c;
|
|
135
|
+
const t = input.take(2);
|
|
136
|
+
if (t === false) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
const n = parseInt(s + t, 16);
|
|
140
|
+
if (isNaN(n)) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
b.push(n);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case "u": {
|
|
147
|
+
const s = input.c;
|
|
148
|
+
const t = input.take(4);
|
|
149
|
+
if (t === false) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const n = parseInt(s + t, 16);
|
|
153
|
+
if (isNaN(n)) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
const chunk = new Uint8Array(4);
|
|
157
|
+
const view = new DataView(chunk.buffer);
|
|
158
|
+
view.setInt32(0, n, true);
|
|
159
|
+
b.push(chunk[0], chunk[1], chunk[2], chunk[3]);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case "U": {
|
|
163
|
+
const s = input.c;
|
|
164
|
+
const t = input.take(8);
|
|
165
|
+
if (t === false) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
const tc = protoInt64.uEnc(s + t);
|
|
169
|
+
const chunk = new Uint8Array(8);
|
|
170
|
+
const view = new DataView(chunk.buffer);
|
|
171
|
+
view.setInt32(0, tc.lo, true);
|
|
172
|
+
view.setInt32(4, tc.hi, true);
|
|
173
|
+
b.push(chunk[0], chunk[1], chunk[2], chunk[3], chunk[4], chunk[5], chunk[6], chunk[7]);
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
b.push(input.c.charCodeAt(0));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return new Uint8Array(b);
|
|
184
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protobuf",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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": {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"build:cjs": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs --declaration --declarationDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
|
|
15
15
|
"build:esm": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module ES2015 --verbatimModuleSyntax --outDir ./dist/esm --declaration --declarationDir ./dist/esm",
|
|
16
16
|
"build:proxy": "node ../../scripts/gen-esm-proxy.mjs .",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
17
|
+
"bootstrap:featureset-defaults": "upstream-inject-feature-defaults src/private/feature-set.ts",
|
|
18
|
+
"prebootstrap:wkt": "rm -rf .tmp && mkdir -p .tmp/google/protobuf && cp -rp src/google/protobuf/* .tmp/google/protobuf",
|
|
19
|
+
"bootstrap:wkt": "protoc --es_out=src --es_opt=bootstrap_wkt=true,ts_nocheck=false,target=ts --proto_path $(upstream-include wkt) $(upstream-files wkt) && license-header src/google/protobuf",
|
|
20
|
+
"postbootstrap:wkt": "diff >/dev/null -r .tmp/google/protobuf src/google/protobuf && cp -rp .tmp/google/protobuf/* src/google/protobuf || true",
|
|
21
21
|
"attw": "attw --pack"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|