@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.
@@ -1,6 +1,7 @@
1
- import type { DescriptorProto, EnumDescriptorProto, EnumValueDescriptorProto, FieldDescriptorProto, FileDescriptorProto, MethodDescriptorProto, OneofDescriptorProto, ServiceDescriptorProto } from "./google/protobuf/descriptor_pb.js";
2
- import type { ScalarType, LongType } from "./field.js";
1
+ import type { DescriptorProto, Edition, EnumDescriptorProto, EnumValueDescriptorProto, FieldDescriptorProto, FileDescriptorProto, MethodDescriptorProto, OneofDescriptorProto, ServiceDescriptorProto } from "./google/protobuf/descriptor_pb.js";
2
+ import type { LongType, ScalarType } from "./field.js";
3
3
  import type { MethodIdempotency, MethodKind } from "./service-type.js";
4
+ import type { MergedFeatureSet } from "./private/feature-set.js";
4
5
  /**
5
6
  * DescriptorSet provides a convenient interface for working with a set
6
7
  * of google.protobuf.FileDescriptorProto.
@@ -50,7 +51,12 @@ export interface DescFile {
50
51
  /**
51
52
  * The syntax specified in the protobuf source.
52
53
  */
53
- readonly syntax: "proto3" | "proto2";
54
+ readonly syntax: "proto3" | "proto2" | "editions";
55
+ /**
56
+ * The edition of the protobuf file. Will be EDITION_PROTO2 for syntax="proto2",
57
+ * EDITION_PROTO3 for syntax="proto3";
58
+ */
59
+ readonly edition: Exclude<Edition, Edition.EDITION_1_TEST_ONLY | Edition.EDITION_2_TEST_ONLY | Edition.EDITION_99997_TEST_ONLY | Edition.EDITION_99998_TEST_ONLY | Edition.EDITION_99999_TEST_ONLY>;
54
60
  /**
55
61
  * The name of the file, excluding the .proto suffix.
56
62
  * For a protobuf file `foo/bar.proto`, this is `foo/bar`.
@@ -91,6 +97,10 @@ export interface DescFile {
91
97
  * Get comments on the package element in the protobuf source.
92
98
  */
93
99
  getPackageComments(): DescComments;
100
+ /**
101
+ * Get the edition features for this protobuf element.
102
+ */
103
+ getFeatures(): MergedFeatureSet;
94
104
  toString(): string;
95
105
  }
96
106
  /**
@@ -135,6 +145,10 @@ export interface DescEnum {
135
145
  * Get comments on the element in the protobuf source.
136
146
  */
137
147
  getComments(): DescComments;
148
+ /**
149
+ * Get the edition features for this protobuf element.
150
+ */
151
+ getFeatures(): MergedFeatureSet;
138
152
  toString(): string;
139
153
  }
140
154
  /**
@@ -171,6 +185,10 @@ export interface DescEnumValue {
171
185
  * Get comments on the element in the protobuf source.
172
186
  */
173
187
  getComments(): DescComments;
188
+ /**
189
+ * Get the edition features for this protobuf element.
190
+ */
191
+ getFeatures(): MergedFeatureSet;
174
192
  toString(): string;
175
193
  }
176
194
  /**
@@ -234,6 +252,10 @@ export interface DescMessage {
234
252
  * Get comments on the element in the protobuf source.
235
253
  */
236
254
  getComments(): DescComments;
255
+ /**
256
+ * Get the edition features for this protobuf element.
257
+ */
258
+ getFeatures(): MergedFeatureSet;
237
259
  toString(): string;
238
260
  }
239
261
  /**
@@ -290,10 +312,14 @@ interface DescFieldCommon {
290
312
  */
291
313
  readonly packed: boolean;
292
314
  /**
293
- * Is this field packed by default? Only valid for enum fields, and for
294
- * scalar fields except BYTES and STRING.
315
+ * Is this field packed by default? Only valid for repeated enum fields, and
316
+ * for repeated scalar fields except BYTES and STRING.
317
+ *
295
318
  * In proto3 syntax, fields are packed by default. In proto2 syntax, fields
296
319
  * are unpacked by default.
320
+ *
321
+ * With editions, the default is whatever the edition specifies as a default.
322
+ * In edition 2023, fields are packed by default.
297
323
  */
298
324
  readonly packedByDefault: boolean;
299
325
  /**
@@ -318,6 +344,10 @@ interface DescFieldCommon {
318
344
  * protobuf source.
319
345
  */
320
346
  declarationString(): string;
347
+ /**
348
+ * Get the edition features for this protobuf element.
349
+ */
350
+ getFeatures(): MergedFeatureSet;
321
351
  toString(): string;
322
352
  }
323
353
  interface DescFieldScalar {
@@ -534,6 +564,10 @@ export interface DescOneof {
534
564
  * Get comments on the element in the protobuf source.
535
565
  */
536
566
  getComments(): DescComments;
567
+ /**
568
+ * Get the edition features for this protobuf element.
569
+ */
570
+ getFeatures(): MergedFeatureSet;
537
571
  toString(): string;
538
572
  }
539
573
  /**
@@ -569,6 +603,10 @@ export interface DescService {
569
603
  * Get comments on the element in the protobuf source.
570
604
  */
571
605
  getComments(): DescComments;
606
+ /**
607
+ * Get the edition features for this protobuf element.
608
+ */
609
+ getFeatures(): MergedFeatureSet;
572
610
  toString(): string;
573
611
  }
574
612
  /**
@@ -612,6 +650,10 @@ export interface DescMethod {
612
650
  * Get comments on the element in the protobuf source.
613
651
  */
614
652
  getComments(): DescComments;
653
+ /**
654
+ * Get the edition features for this protobuf element.
655
+ */
656
+ getFeatures(): MergedFeatureSet;
615
657
  toString(): string;
616
658
  }
617
659
  /**
@@ -237,7 +237,7 @@ export class Any extends Message {
237
237
  throw new Error(`invalid type url: ${url}`);
238
238
  }
239
239
  const slash = url.lastIndexOf("/");
240
- const name = slash > 0 ? url.substring(slash + 1) : url;
240
+ const name = slash >= 0 ? url.substring(slash + 1) : url;
241
241
  if (!name.length) {
242
242
  throw new Error(`invalid type url: ${url}`);
243
243
  }
@@ -1,9 +1,66 @@
1
+ import { proto2 } from "../../proto2.js";
1
2
  import type { PartialMessage, PlainMessage } from "../../message.js";
2
3
  import { Message } from "../../message.js";
3
- import { proto2 } from "../../proto2.js";
4
4
  import type { FieldList } from "../../field-list.js";
5
5
  import type { BinaryReadOptions } from "../../binary-format.js";
6
6
  import type { JsonReadOptions, JsonValue } from "../../json-format.js";
7
+ /**
8
+ * The full set of known editions.
9
+ *
10
+ * @generated from enum google.protobuf.Edition
11
+ */
12
+ export declare enum Edition {
13
+ /**
14
+ * A placeholder for an unknown edition value.
15
+ *
16
+ * @generated from enum value: EDITION_UNKNOWN = 0;
17
+ */
18
+ EDITION_UNKNOWN = 0,
19
+ /**
20
+ * Legacy syntax "editions". These pre-date editions, but behave much like
21
+ * distinct editions. These can't be used to specify the edition of proto
22
+ * files, but feature definitions must supply proto2/proto3 defaults for
23
+ * backwards compatibility.
24
+ *
25
+ * @generated from enum value: EDITION_PROTO2 = 998;
26
+ */
27
+ EDITION_PROTO2 = 998,
28
+ /**
29
+ * @generated from enum value: EDITION_PROTO3 = 999;
30
+ */
31
+ EDITION_PROTO3 = 999,
32
+ /**
33
+ * Editions that have been released. The specific values are arbitrary and
34
+ * should not be depended on, but they will always be time-ordered for easy
35
+ * comparison.
36
+ *
37
+ * @generated from enum value: EDITION_2023 = 1000;
38
+ */
39
+ EDITION_2023 = 1000,
40
+ /**
41
+ * Placeholder editions for testing feature resolution. These should not be
42
+ * used or relyed on outside of tests.
43
+ *
44
+ * @generated from enum value: EDITION_1_TEST_ONLY = 1;
45
+ */
46
+ EDITION_1_TEST_ONLY = 1,
47
+ /**
48
+ * @generated from enum value: EDITION_2_TEST_ONLY = 2;
49
+ */
50
+ EDITION_2_TEST_ONLY = 2,
51
+ /**
52
+ * @generated from enum value: EDITION_99997_TEST_ONLY = 99997;
53
+ */
54
+ EDITION_99997_TEST_ONLY = 99997,
55
+ /**
56
+ * @generated from enum value: EDITION_99998_TEST_ONLY = 99998;
57
+ */
58
+ EDITION_99998_TEST_ONLY = 99998,
59
+ /**
60
+ * @generated from enum value: EDITION_99999_TEST_ONLY = 99999;
61
+ */
62
+ EDITION_99999_TEST_ONLY = 99999
63
+ }
7
64
  /**
8
65
  * The protocol compiler can output a FileDescriptorSet containing the .proto
9
66
  * files it parses.
@@ -102,11 +159,11 @@ export declare class FileDescriptorProto extends Message<FileDescriptorProto> {
102
159
  */
103
160
  syntax?: string;
104
161
  /**
105
- * The edition of the proto file, which is an opaque string.
162
+ * The edition of the proto file.
106
163
  *
107
- * @generated from field: optional string edition = 13;
164
+ * @generated from field: optional google.protobuf.Edition edition = 14;
108
165
  */
109
- edition?: string;
166
+ edition?: Edition;
110
167
  constructor(data?: PartialMessage<FileDescriptorProto>);
111
168
  static readonly runtime: typeof proto2;
112
169
  static readonly typeName = "google.protobuf.FileDescriptorProto";
@@ -258,7 +315,7 @@ export declare class ExtensionRangeOptions extends Message<ExtensionRangeOptions
258
315
  features?: FeatureSet;
259
316
  /**
260
317
  * The verification state of the range.
261
- * TODO(b/278783756): flip the default to DECLARATION once all empty ranges
318
+ * TODO: flip the default to DECLARATION once all empty ranges
262
319
  * are marked as UNVERIFIED.
263
320
  *
264
321
  * @generated from field: optional google.protobuf.ExtensionRangeOptions.VerificationState verification = 3 [default = UNVERIFIED];
@@ -496,9 +553,10 @@ export declare enum FieldDescriptorProto_Type {
496
553
  STRING = 9,
497
554
  /**
498
555
  * Tag-delimited aggregate.
499
- * Group type is deprecated and not supported in proto3. However, Proto3
556
+ * Group type is deprecated and not supported after google.protobuf. However, Proto3
500
557
  * implementations should still be able to parse the group wire format and
501
- * treat group fields as unknown fields.
558
+ * treat group fields as unknown fields. In Editions, the group wire format
559
+ * can be enabled via the `message_encoding` feature.
502
560
  *
503
561
  * @generated from enum value: TYPE_GROUP = 10;
504
562
  */
@@ -555,13 +613,17 @@ export declare enum FieldDescriptorProto_Label {
555
613
  */
556
614
  OPTIONAL = 1,
557
615
  /**
558
- * @generated from enum value: LABEL_REQUIRED = 2;
616
+ * @generated from enum value: LABEL_REPEATED = 3;
559
617
  */
560
- REQUIRED = 2,
618
+ REPEATED = 3,
561
619
  /**
562
- * @generated from enum value: LABEL_REPEATED = 3;
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;
563
625
  */
564
- REPEATED = 3
626
+ REQUIRED = 2
565
627
  }
566
628
  /**
567
629
  * Describes a oneof.
@@ -1050,7 +1112,7 @@ export declare class MessageOptions extends Message<MessageOptions> {
1050
1112
  * This should only be used as a temporary measure against broken builds due
1051
1113
  * to the change in behavior for JSON field name conflicts.
1052
1114
  *
1053
- * TODO(b/261750190) This is legacy behavior we plan to remove once downstream
1115
+ * TODO This is legacy behavior we plan to remove once downstream
1054
1116
  * teams have had time to migrate.
1055
1117
  *
1056
1118
  * @generated from field: optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
@@ -1098,7 +1160,9 @@ export declare class FieldOptions extends Message<FieldOptions> {
1098
1160
  * a more efficient representation on the wire. Rather than repeatedly
1099
1161
  * writing the tag and type for each element, the entire array is encoded as
1100
1162
  * a single length-delimited blob. In proto3, only explicit setting it to
1101
- * false will avoid using packed encoding.
1163
+ * false will avoid using packed encoding. This option is prohibited in
1164
+ * Editions, but the `repeated_field_encoding` feature can be used to control
1165
+ * the behavior.
1102
1166
  *
1103
1167
  * @generated from field: optional bool packed = 2;
1104
1168
  */
@@ -1342,9 +1406,9 @@ export declare enum FieldOptions_OptionTargetType {
1342
1406
  */
1343
1407
  export declare class FieldOptions_EditionDefault extends Message<FieldOptions_EditionDefault> {
1344
1408
  /**
1345
- * @generated from field: optional string edition = 1;
1409
+ * @generated from field: optional google.protobuf.Edition edition = 3;
1346
1410
  */
1347
- edition?: string;
1411
+ edition?: Edition;
1348
1412
  /**
1349
1413
  * Textproto value.
1350
1414
  *
@@ -1410,7 +1474,7 @@ export declare class EnumOptions extends Message<EnumOptions> {
1410
1474
  * and strips underscored from the fields before comparison in proto3 only.
1411
1475
  * The new behavior takes `json_name` into account and applies to proto2 as
1412
1476
  * well.
1413
- * TODO(b/261750190) Remove this legacy behavior once downstream teams have
1477
+ * TODO Remove this legacy behavior once downstream teams have
1414
1478
  * had time to migrate.
1415
1479
  *
1416
1480
  * @generated from field: optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
@@ -1656,7 +1720,7 @@ export declare class UninterpretedOption_NamePart extends Message<UninterpretedO
1656
1720
  static equals(a: UninterpretedOption_NamePart | PlainMessage<UninterpretedOption_NamePart> | undefined, b: UninterpretedOption_NamePart | PlainMessage<UninterpretedOption_NamePart> | undefined): boolean;
1657
1721
  }
1658
1722
  /**
1659
- * TODO(b/274655146) Enums in C++ gencode (and potentially other languages) are
1723
+ * TODO Enums in C++ gencode (and potentially other languages) are
1660
1724
  * not well scoped. This means that each of the feature enums below can clash
1661
1725
  * with each other. The short names we've chosen maximize call-site
1662
1726
  * readability, but leave us very open to this scenario. A future feature will
@@ -1679,9 +1743,9 @@ export declare class FeatureSet extends Message<FeatureSet> {
1679
1743
  */
1680
1744
  repeatedFieldEncoding?: FeatureSet_RepeatedFieldEncoding;
1681
1745
  /**
1682
- * @generated from field: optional google.protobuf.FeatureSet.StringFieldValidation string_field_validation = 4;
1746
+ * @generated from field: optional google.protobuf.FeatureSet.Utf8Validation utf8_validation = 4;
1683
1747
  */
1684
- stringFieldValidation?: FeatureSet_StringFieldValidation;
1748
+ utf8Validation?: FeatureSet_Utf8Validation;
1685
1749
  /**
1686
1750
  * @generated from field: optional google.protobuf.FeatureSet.MessageEncoding message_encoding = 5;
1687
1751
  */
@@ -1690,10 +1754,6 @@ export declare class FeatureSet extends Message<FeatureSet> {
1690
1754
  * @generated from field: optional google.protobuf.FeatureSet.JsonFormat json_format = 6;
1691
1755
  */
1692
1756
  jsonFormat?: FeatureSet_JsonFormat;
1693
- /**
1694
- * @generated from field: optional google.protobuf.FeatureSet raw_features = 999;
1695
- */
1696
- rawFeatures?: FeatureSet;
1697
1757
  constructor(data?: PartialMessage<FeatureSet>);
1698
1758
  static readonly runtime: typeof proto2;
1699
1759
  static readonly typeName = "google.protobuf.FeatureSet";
@@ -1759,25 +1819,21 @@ export declare enum FeatureSet_RepeatedFieldEncoding {
1759
1819
  EXPANDED = 2
1760
1820
  }
1761
1821
  /**
1762
- * @generated from enum google.protobuf.FeatureSet.StringFieldValidation
1822
+ * @generated from enum google.protobuf.FeatureSet.Utf8Validation
1763
1823
  */
1764
- export declare enum FeatureSet_StringFieldValidation {
1765
- /**
1766
- * @generated from enum value: STRING_FIELD_VALIDATION_UNKNOWN = 0;
1767
- */
1768
- STRING_FIELD_VALIDATION_UNKNOWN = 0,
1824
+ export declare enum FeatureSet_Utf8Validation {
1769
1825
  /**
1770
- * @generated from enum value: MANDATORY = 1;
1826
+ * @generated from enum value: UTF8_VALIDATION_UNKNOWN = 0;
1771
1827
  */
1772
- MANDATORY = 1,
1828
+ UTF8_VALIDATION_UNKNOWN = 0,
1773
1829
  /**
1774
- * @generated from enum value: HINT = 2;
1830
+ * @generated from enum value: NONE = 1;
1775
1831
  */
1776
- HINT = 2,
1832
+ NONE = 1,
1777
1833
  /**
1778
- * @generated from enum value: NONE = 3;
1834
+ * @generated from enum value: VERIFY = 2;
1779
1835
  */
1780
- NONE = 3
1836
+ VERIFY = 2
1781
1837
  }
1782
1838
  /**
1783
1839
  * @generated from enum google.protobuf.FeatureSet.MessageEncoding
@@ -1813,6 +1869,68 @@ export declare enum FeatureSet_JsonFormat {
1813
1869
  */
1814
1870
  LEGACY_BEST_EFFORT = 2
1815
1871
  }
1872
+ /**
1873
+ * A compiled specification for the defaults of a set of features. These
1874
+ * messages are generated from FeatureSet extensions and can be used to seed
1875
+ * feature resolution. The resolution with this object becomes a simple search
1876
+ * for the closest matching edition, followed by proto merges.
1877
+ *
1878
+ * @generated from message google.protobuf.FeatureSetDefaults
1879
+ */
1880
+ export declare class FeatureSetDefaults extends Message<FeatureSetDefaults> {
1881
+ /**
1882
+ * @generated from field: repeated google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault defaults = 1;
1883
+ */
1884
+ defaults: FeatureSetDefaults_FeatureSetEditionDefault[];
1885
+ /**
1886
+ * The minimum supported edition (inclusive) when this was constructed.
1887
+ * Editions before this will not have defaults.
1888
+ *
1889
+ * @generated from field: optional google.protobuf.Edition minimum_edition = 4;
1890
+ */
1891
+ minimumEdition?: Edition;
1892
+ /**
1893
+ * The maximum known edition (inclusive) when this was constructed. Editions
1894
+ * after this will not have reliable defaults.
1895
+ *
1896
+ * @generated from field: optional google.protobuf.Edition maximum_edition = 5;
1897
+ */
1898
+ maximumEdition?: Edition;
1899
+ constructor(data?: PartialMessage<FeatureSetDefaults>);
1900
+ static readonly runtime: typeof proto2;
1901
+ static readonly typeName = "google.protobuf.FeatureSetDefaults";
1902
+ static readonly fields: FieldList;
1903
+ static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): FeatureSetDefaults;
1904
+ static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): FeatureSetDefaults;
1905
+ static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): FeatureSetDefaults;
1906
+ static equals(a: FeatureSetDefaults | PlainMessage<FeatureSetDefaults> | undefined, b: FeatureSetDefaults | PlainMessage<FeatureSetDefaults> | undefined): boolean;
1907
+ }
1908
+ /**
1909
+ * A map from every known edition with a unique set of defaults to its
1910
+ * defaults. Not all editions may be contained here. For a given edition,
1911
+ * the defaults at the closest matching edition ordered at or before it should
1912
+ * be used. This field must be in strict ascending order by edition.
1913
+ *
1914
+ * @generated from message google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault
1915
+ */
1916
+ export declare class FeatureSetDefaults_FeatureSetEditionDefault extends Message<FeatureSetDefaults_FeatureSetEditionDefault> {
1917
+ /**
1918
+ * @generated from field: optional google.protobuf.Edition edition = 3;
1919
+ */
1920
+ edition?: Edition;
1921
+ /**
1922
+ * @generated from field: optional google.protobuf.FeatureSet features = 2;
1923
+ */
1924
+ features?: FeatureSet;
1925
+ constructor(data?: PartialMessage<FeatureSetDefaults_FeatureSetEditionDefault>);
1926
+ static readonly runtime: typeof proto2;
1927
+ static readonly typeName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault";
1928
+ static readonly fields: FieldList;
1929
+ static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): FeatureSetDefaults_FeatureSetEditionDefault;
1930
+ static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): FeatureSetDefaults_FeatureSetEditionDefault;
1931
+ static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): FeatureSetDefaults_FeatureSetEditionDefault;
1932
+ static equals(a: FeatureSetDefaults_FeatureSetEditionDefault | PlainMessage<FeatureSetDefaults_FeatureSetEditionDefault> | undefined, b: FeatureSetDefaults_FeatureSetEditionDefault | PlainMessage<FeatureSetDefaults_FeatureSetEditionDefault> | undefined): boolean;
1933
+ }
1816
1934
  /**
1817
1935
  * Encapsulates information about the original source file from which a
1818
1936
  * FileDescriptorProto was generated.