@bufbuild/protobuf 1.7.2 → 1.8.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/codegen-info.d.ts +6 -1
- package/dist/cjs/codegen-info.js +4 -3
- package/dist/cjs/create-descriptor-set.js +45 -33
- package/dist/cjs/create-registry-from-desc.js +60 -110
- package/dist/cjs/descriptor-set.d.ts +13 -9
- package/dist/cjs/field.d.ts +25 -51
- package/dist/cjs/field.js +0 -66
- package/dist/cjs/google/protobuf/compiler/plugin_pb.d.ts +18 -0
- package/dist/cjs/google/protobuf/compiler/plugin_pb.js +2 -0
- package/dist/cjs/google/protobuf/descriptor_pb.d.ts +33 -33
- package/dist/cjs/google/protobuf/descriptor_pb.js +23 -10
- package/dist/cjs/google/protobuf/struct_pb.js +1 -1
- package/dist/cjs/google/protobuf/type_pb.js +1 -1
- package/dist/cjs/google/protobuf/wrappers_pb.js +19 -19
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.js +6 -4
- package/dist/cjs/is-message.d.ts +22 -0
- package/dist/cjs/is-message.js +52 -0
- package/dist/cjs/json-format.d.ts +1 -2
- package/dist/cjs/private/binary-format.d.ts +7 -0
- package/dist/cjs/private/{binary-format-common.js → binary-format.js} +150 -53
- package/dist/cjs/private/extensions.js +1 -1
- package/dist/cjs/private/feature-set.js +1 -1
- package/dist/cjs/private/field-normalize.d.ts +9 -0
- package/dist/cjs/private/field-normalize.js +69 -0
- package/dist/cjs/private/field-wrapper.d.ts +1 -1
- package/dist/cjs/private/field-wrapper.js +12 -12
- package/dist/cjs/private/field.d.ts +1 -0
- package/dist/cjs/private/field.js +1 -0
- package/dist/cjs/private/json-format.d.ts +2 -0
- package/dist/cjs/private/{json-format-common.js → json-format.js} +261 -170
- package/dist/cjs/private/proto-runtime.d.ts +1 -1
- package/dist/cjs/private/proto-runtime.js +8 -4
- package/dist/cjs/private/reflect.d.ts +9 -0
- package/dist/cjs/private/reflect.js +79 -0
- package/dist/cjs/private/reify-wkt.js +11 -11
- package/dist/cjs/private/scalars.d.ts +9 -18
- package/dist/cjs/private/scalars.js +36 -80
- package/dist/cjs/private/text-format.d.ts +1 -1
- package/dist/cjs/private/text-format.js +17 -17
- package/dist/cjs/private/util-common.js +17 -14
- package/dist/cjs/proto-delimited.js +2 -3
- package/dist/cjs/proto2.js +29 -68
- package/dist/cjs/proto3.js +30 -77
- package/dist/cjs/scalar.d.ts +53 -0
- package/dist/cjs/scalar.js +81 -0
- package/dist/cjs/to-plain-message.js +3 -4
- package/dist/esm/codegen-info.d.ts +6 -1
- package/dist/esm/codegen-info.js +6 -5
- package/dist/esm/create-descriptor-set.js +22 -10
- package/dist/esm/create-registry-from-desc.js +62 -111
- package/dist/esm/descriptor-set.d.ts +13 -9
- package/dist/esm/descriptor-set.js +1 -1
- package/dist/esm/field.d.ts +25 -51
- package/dist/esm/field.js +1 -65
- package/dist/esm/google/protobuf/compiler/plugin_pb.d.ts +18 -0
- package/dist/esm/google/protobuf/compiler/plugin_pb.js +2 -0
- package/dist/esm/google/protobuf/descriptor_pb.d.ts +33 -33
- package/dist/esm/google/protobuf/descriptor_pb.js +23 -10
- package/dist/esm/google/protobuf/struct_pb.js +1 -1
- package/dist/esm/google/protobuf/type_pb.js +1 -1
- package/dist/esm/google/protobuf/wrappers_pb.js +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/is-message.d.ts +22 -0
- package/dist/esm/is-message.js +48 -0
- package/dist/esm/json-format.d.ts +1 -2
- package/dist/esm/json-format.js +1 -1
- package/dist/esm/private/binary-format.d.ts +7 -0
- package/dist/esm/private/{binary-format-common.js → binary-format.js} +126 -25
- package/dist/esm/private/extensions.js +2 -2
- package/dist/esm/private/feature-set.js +1 -1
- package/dist/esm/private/field-normalize.d.ts +9 -0
- package/dist/esm/private/field-normalize.js +65 -0
- package/dist/esm/private/field-wrapper.d.ts +1 -1
- package/dist/esm/private/field-wrapper.js +3 -2
- package/dist/esm/private/field.d.ts +1 -0
- package/dist/esm/private/field.js +1 -0
- package/dist/esm/private/json-format.d.ts +2 -0
- package/dist/esm/private/{json-format-common.js → json-format.js} +227 -135
- package/dist/esm/private/proto-runtime.d.ts +1 -1
- package/dist/esm/private/proto-runtime.js +8 -4
- package/dist/esm/private/reflect.d.ts +9 -0
- package/dist/esm/private/reflect.js +74 -0
- package/dist/esm/private/reify-wkt.js +1 -1
- package/dist/esm/private/scalars.d.ts +9 -18
- package/dist/esm/private/scalars.js +15 -59
- package/dist/esm/private/text-format.d.ts +1 -1
- package/dist/esm/private/text-format.js +1 -1
- package/dist/esm/private/util-common.js +10 -6
- package/dist/esm/proto-delimited.js +2 -3
- package/dist/esm/proto2.js +29 -68
- package/dist/esm/proto3.js +31 -78
- package/dist/esm/scalar.d.ts +53 -0
- package/dist/esm/scalar.js +78 -0
- package/dist/esm/to-plain-message.js +3 -2
- package/package.json +2 -8
- package/dist/cjs/private/binary-format-common.d.ts +0 -13
- package/dist/cjs/private/binary-format-proto2.d.ts +0 -2
- package/dist/cjs/private/binary-format-proto2.js +0 -91
- package/dist/cjs/private/binary-format-proto3.d.ts +0 -2
- package/dist/cjs/private/binary-format-proto3.js +0 -83
- package/dist/cjs/private/json-format-common.d.ts +0 -9
- package/dist/cjs/private/json-format-proto2.d.ts +0 -2
- package/dist/cjs/private/json-format-proto2.js +0 -103
- package/dist/cjs/private/json-format-proto3.d.ts +0 -2
- package/dist/cjs/private/json-format-proto3.js +0 -94
- package/dist/esm/private/binary-format-common.d.ts +0 -13
- package/dist/esm/private/binary-format-proto2.d.ts +0 -2
- package/dist/esm/private/binary-format-proto2.js +0 -87
- package/dist/esm/private/binary-format-proto3.d.ts +0 -2
- package/dist/esm/private/binary-format-proto3.js +0 -79
- package/dist/esm/private/json-format-common.d.ts +0 -9
- package/dist/esm/private/json-format-proto2.d.ts +0 -2
- package/dist/esm/private/json-format-proto2.js +0 -99
- package/dist/esm/private/json-format-proto3.d.ts +0 -2
- package/dist/esm/private/json-format-proto3.js +0 -90
- package/dist/proxy/index.d.ts +0 -1
- package/dist/proxy/index.js +0 -1
|
@@ -37,6 +37,10 @@ export declare enum Edition {
|
|
|
37
37
|
* @generated from enum value: EDITION_2023 = 1000;
|
|
38
38
|
*/
|
|
39
39
|
EDITION_2023 = 1000,
|
|
40
|
+
/**
|
|
41
|
+
* @generated from enum value: EDITION_2024 = 1001;
|
|
42
|
+
*/
|
|
43
|
+
EDITION_2024 = 1001,
|
|
40
44
|
/**
|
|
41
45
|
* Placeholder editions for testing feature resolution. These should not be
|
|
42
46
|
* used or relyed on outside of tests.
|
|
@@ -59,7 +63,15 @@ export declare enum Edition {
|
|
|
59
63
|
/**
|
|
60
64
|
* @generated from enum value: EDITION_99999_TEST_ONLY = 99999;
|
|
61
65
|
*/
|
|
62
|
-
EDITION_99999_TEST_ONLY = 99999
|
|
66
|
+
EDITION_99999_TEST_ONLY = 99999,
|
|
67
|
+
/**
|
|
68
|
+
* Placeholder for specifying unbounded edition support. This should only
|
|
69
|
+
* ever be used by plugins that can expect to never require any changes to
|
|
70
|
+
* support a new edition.
|
|
71
|
+
*
|
|
72
|
+
* @generated from enum value: EDITION_MAX = 2147483647;
|
|
73
|
+
*/
|
|
74
|
+
EDITION_MAX = 2147483647
|
|
63
75
|
}
|
|
64
76
|
/**
|
|
65
77
|
* The protocol compiler can output a FileDescriptorSet containing the .proto
|
|
@@ -471,12 +483,12 @@ export declare class FieldDescriptorProto extends Message<FieldDescriptorProto>
|
|
|
471
483
|
* If true, this is a proto3 "optional". When a proto3 field is optional, it
|
|
472
484
|
* tracks presence regardless of field type.
|
|
473
485
|
*
|
|
474
|
-
* When proto3_optional is true, this field must
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
486
|
+
* When proto3_optional is true, this field must belong to a oneof to signal
|
|
487
|
+
* to old proto3 clients that presence is tracked for this field. This oneof
|
|
488
|
+
* is known as a "synthetic" oneof, and this field must be its sole member
|
|
489
|
+
* (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs
|
|
490
|
+
* exist in the descriptor only, and do not generate any API. Synthetic oneofs
|
|
491
|
+
* must be ordered after all "real" oneofs.
|
|
480
492
|
*
|
|
481
493
|
* For message fields, proto3_optional doesn't create any semantic change,
|
|
482
494
|
* since non-repeated message fields always track presence. However it still
|
|
@@ -911,10 +923,6 @@ export declare class FileOptions extends Message<FileOptions> {
|
|
|
911
923
|
* @generated from field: optional bool py_generic_services = 18 [default = false];
|
|
912
924
|
*/
|
|
913
925
|
pyGenericServices?: boolean;
|
|
914
|
-
/**
|
|
915
|
-
* @generated from field: optional bool php_generic_services = 42 [default = false];
|
|
916
|
-
*/
|
|
917
|
-
phpGenericServices?: boolean;
|
|
918
926
|
/**
|
|
919
927
|
* Is this file deprecated?
|
|
920
928
|
* Depending on the target platform, this can emit Deprecated annotations
|
|
@@ -1078,10 +1086,6 @@ export declare class MessageOptions extends Message<MessageOptions> {
|
|
|
1078
1086
|
*/
|
|
1079
1087
|
deprecated?: boolean;
|
|
1080
1088
|
/**
|
|
1081
|
-
* NOTE: Do not set the option in .proto files. Always use the maps syntax
|
|
1082
|
-
* instead. The option should only be implicitly set by the proto compiler
|
|
1083
|
-
* parser.
|
|
1084
|
-
*
|
|
1085
1089
|
* Whether the message is an automatically generated map entry type for the
|
|
1086
1090
|
* maps field.
|
|
1087
1091
|
*
|
|
@@ -1100,6 +1104,10 @@ export declare class MessageOptions extends Message<MessageOptions> {
|
|
|
1100
1104
|
* The reflection APIs in such implementations still need to work as
|
|
1101
1105
|
* if the field is a repeated message field.
|
|
1102
1106
|
*
|
|
1107
|
+
* NOTE: Do not set the option in .proto files. Always use the maps syntax
|
|
1108
|
+
* instead. The option should only be implicitly set by the proto compiler
|
|
1109
|
+
* parser.
|
|
1110
|
+
*
|
|
1103
1111
|
* @generated from field: optional bool map_entry = 7;
|
|
1104
1112
|
*/
|
|
1105
1113
|
mapEntry?: boolean;
|
|
@@ -1201,19 +1209,11 @@ export declare class FieldOptions extends Message<FieldOptions> {
|
|
|
1201
1209
|
* call from multiple threads concurrently, while non-const methods continue
|
|
1202
1210
|
* to require exclusive access.
|
|
1203
1211
|
*
|
|
1204
|
-
* Note that
|
|
1205
|
-
*
|
|
1206
|
-
*
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1209
|
-
* parsing. An implementation which chooses not to check required fields
|
|
1210
|
-
* must be consistent about it. That is, for any particular sub-message, the
|
|
1211
|
-
* implementation must either *always* check its required fields, or *never*
|
|
1212
|
-
* check its required fields, regardless of whether or not the message has
|
|
1213
|
-
* been parsed.
|
|
1214
|
-
*
|
|
1215
|
-
* As of May 2022, lazy verifies the contents of the byte stream during
|
|
1216
|
-
* parsing. An invalid byte stream will cause the overall parsing to fail.
|
|
1212
|
+
* Note that lazy message fields are still eagerly verified to check
|
|
1213
|
+
* ill-formed wireformat or missing required fields. Calling IsInitialized()
|
|
1214
|
+
* on the outer message would fail if the inner message has missing required
|
|
1215
|
+
* fields. Failed verification would result in parsing failure (except when
|
|
1216
|
+
* uninitialized messages are acceptable).
|
|
1217
1217
|
*
|
|
1218
1218
|
* @generated from field: optional bool lazy = 5 [default = false];
|
|
1219
1219
|
*/
|
|
@@ -1827,13 +1827,13 @@ export declare enum FeatureSet_Utf8Validation {
|
|
|
1827
1827
|
*/
|
|
1828
1828
|
UTF8_VALIDATION_UNKNOWN = 0,
|
|
1829
1829
|
/**
|
|
1830
|
-
* @generated from enum value:
|
|
1830
|
+
* @generated from enum value: VERIFY = 2;
|
|
1831
1831
|
*/
|
|
1832
|
-
|
|
1832
|
+
VERIFY = 2,
|
|
1833
1833
|
/**
|
|
1834
|
-
* @generated from enum value:
|
|
1834
|
+
* @generated from enum value: NONE = 3;
|
|
1835
1835
|
*/
|
|
1836
|
-
|
|
1836
|
+
NONE = 3
|
|
1837
1837
|
}
|
|
1838
1838
|
/**
|
|
1839
1839
|
* @generated from enum google.protobuf.FeatureSet.MessageEncoding
|
|
@@ -2004,7 +2004,7 @@ export declare class SourceCodeInfo_Location extends Message<SourceCodeInfo_Loca
|
|
|
2004
2004
|
* location.
|
|
2005
2005
|
*
|
|
2006
2006
|
* Each element is a field number or an index. They form a path from
|
|
2007
|
-
* the root FileDescriptorProto to the place where the definition
|
|
2007
|
+
* the root FileDescriptorProto to the place where the definition appears.
|
|
2008
2008
|
* For example, this path:
|
|
2009
2009
|
* [ 4, 3, 2, 7, 1 ]
|
|
2010
2010
|
* refers to:
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// The messages in this file describe the definitions found in .proto files.
|
|
19
19
|
// A valid .proto file can be translated directly to a FileDescriptorProto
|
|
20
20
|
// without any other information (e.g. without reading its imports).
|
|
21
|
-
// @generated by protoc-gen-es v1.
|
|
21
|
+
// @generated by protoc-gen-es v1.8.0 with parameter "bootstrap_wkt=true,ts_nocheck=false,target=ts"
|
|
22
22
|
// @generated from file google/protobuf/descriptor.proto (package google.protobuf, syntax proto2)
|
|
23
23
|
/* eslint-disable */
|
|
24
24
|
import { proto2 } from "../../proto2.js";
|
|
@@ -57,6 +57,10 @@ export var Edition;
|
|
|
57
57
|
* @generated from enum value: EDITION_2023 = 1000;
|
|
58
58
|
*/
|
|
59
59
|
Edition[Edition["EDITION_2023"] = 1000] = "EDITION_2023";
|
|
60
|
+
/**
|
|
61
|
+
* @generated from enum value: EDITION_2024 = 1001;
|
|
62
|
+
*/
|
|
63
|
+
Edition[Edition["EDITION_2024"] = 1001] = "EDITION_2024";
|
|
60
64
|
/**
|
|
61
65
|
* Placeholder editions for testing feature resolution. These should not be
|
|
62
66
|
* used or relyed on outside of tests.
|
|
@@ -80,6 +84,14 @@ export var Edition;
|
|
|
80
84
|
* @generated from enum value: EDITION_99999_TEST_ONLY = 99999;
|
|
81
85
|
*/
|
|
82
86
|
Edition[Edition["EDITION_99999_TEST_ONLY"] = 99999] = "EDITION_99999_TEST_ONLY";
|
|
87
|
+
/**
|
|
88
|
+
* Placeholder for specifying unbounded edition support. This should only
|
|
89
|
+
* ever be used by plugins that can expect to never require any changes to
|
|
90
|
+
* support a new edition.
|
|
91
|
+
*
|
|
92
|
+
* @generated from enum value: EDITION_MAX = 2147483647;
|
|
93
|
+
*/
|
|
94
|
+
Edition[Edition["EDITION_MAX"] = 2147483647] = "EDITION_MAX";
|
|
83
95
|
})(Edition || (Edition = {}));
|
|
84
96
|
// Retrieve enum metadata with: proto2.getEnumType(Edition)
|
|
85
97
|
proto2.util.setEnumType(Edition, "google.protobuf.Edition", [
|
|
@@ -87,11 +99,13 @@ proto2.util.setEnumType(Edition, "google.protobuf.Edition", [
|
|
|
87
99
|
{ no: 998, name: "EDITION_PROTO2" },
|
|
88
100
|
{ no: 999, name: "EDITION_PROTO3" },
|
|
89
101
|
{ no: 1000, name: "EDITION_2023" },
|
|
102
|
+
{ no: 1001, name: "EDITION_2024" },
|
|
90
103
|
{ no: 1, name: "EDITION_1_TEST_ONLY" },
|
|
91
104
|
{ no: 2, name: "EDITION_2_TEST_ONLY" },
|
|
92
105
|
{ no: 99997, name: "EDITION_99997_TEST_ONLY" },
|
|
93
106
|
{ no: 99998, name: "EDITION_99998_TEST_ONLY" },
|
|
94
107
|
{ no: 99999, name: "EDITION_99999_TEST_ONLY" },
|
|
108
|
+
{ no: 2147483647, name: "EDITION_MAX" },
|
|
95
109
|
]);
|
|
96
110
|
/**
|
|
97
111
|
* The protocol compiler can output a FileDescriptorSet containing the .proto
|
|
@@ -872,7 +886,6 @@ FileOptions.fields = proto2.util.newFieldList(() => [
|
|
|
872
886
|
{ no: 16, name: "cc_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
|
|
873
887
|
{ no: 17, name: "java_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
|
|
874
888
|
{ no: 18, name: "py_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
|
|
875
|
-
{ no: 42, name: "php_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
|
|
876
889
|
{ no: 23, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
|
|
877
890
|
{ no: 31, name: "cc_enable_arenas", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: true },
|
|
878
891
|
{ no: 36, name: "objc_class_prefix", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
|
|
@@ -1469,8 +1482,8 @@ export class UninterpretedOption_NamePart extends Message {
|
|
|
1469
1482
|
UninterpretedOption_NamePart.runtime = proto2;
|
|
1470
1483
|
UninterpretedOption_NamePart.typeName = "google.protobuf.UninterpretedOption.NamePart";
|
|
1471
1484
|
UninterpretedOption_NamePart.fields = proto2.util.newFieldList(() => [
|
|
1472
|
-
{ no: 1, name: "name_part", kind: "scalar", T: 9 /* ScalarType.STRING
|
|
1473
|
-
{ no: 2, name: "is_extension", kind: "scalar", T: 8 /* ScalarType.BOOL
|
|
1485
|
+
{ no: 1, name: "name_part", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true },
|
|
1486
|
+
{ no: 2, name: "is_extension", kind: "scalar", T: 8 /* ScalarType.BOOL */, req: true },
|
|
1474
1487
|
]);
|
|
1475
1488
|
/**
|
|
1476
1489
|
* TODO Enums in C++ gencode (and potentially other languages) are
|
|
@@ -1596,20 +1609,20 @@ export var FeatureSet_Utf8Validation;
|
|
|
1596
1609
|
* @generated from enum value: UTF8_VALIDATION_UNKNOWN = 0;
|
|
1597
1610
|
*/
|
|
1598
1611
|
FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["UTF8_VALIDATION_UNKNOWN"] = 0] = "UTF8_VALIDATION_UNKNOWN";
|
|
1599
|
-
/**
|
|
1600
|
-
* @generated from enum value: NONE = 1;
|
|
1601
|
-
*/
|
|
1602
|
-
FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["NONE"] = 1] = "NONE";
|
|
1603
1612
|
/**
|
|
1604
1613
|
* @generated from enum value: VERIFY = 2;
|
|
1605
1614
|
*/
|
|
1606
1615
|
FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["VERIFY"] = 2] = "VERIFY";
|
|
1616
|
+
/**
|
|
1617
|
+
* @generated from enum value: NONE = 3;
|
|
1618
|
+
*/
|
|
1619
|
+
FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["NONE"] = 3] = "NONE";
|
|
1607
1620
|
})(FeatureSet_Utf8Validation || (FeatureSet_Utf8Validation = {}));
|
|
1608
1621
|
// Retrieve enum metadata with: proto2.getEnumType(FeatureSet_Utf8Validation)
|
|
1609
1622
|
proto2.util.setEnumType(FeatureSet_Utf8Validation, "google.protobuf.FeatureSet.Utf8Validation", [
|
|
1610
1623
|
{ no: 0, name: "UTF8_VALIDATION_UNKNOWN" },
|
|
1611
|
-
{ no: 1, name: "NONE" },
|
|
1612
1624
|
{ no: 2, name: "VERIFY" },
|
|
1625
|
+
{ no: 3, name: "NONE" },
|
|
1613
1626
|
]);
|
|
1614
1627
|
/**
|
|
1615
1628
|
* @generated from enum google.protobuf.FeatureSet.MessageEncoding
|
|
@@ -1816,7 +1829,7 @@ export class SourceCodeInfo_Location extends Message {
|
|
|
1816
1829
|
* location.
|
|
1817
1830
|
*
|
|
1818
1831
|
* Each element is a field number or an index. They form a path from
|
|
1819
|
-
* the root FileDescriptorProto to the place where the definition
|
|
1832
|
+
* the root FileDescriptorProto to the place where the definition appears.
|
|
1820
1833
|
* For example, this path:
|
|
1821
1834
|
* [ 4, 3, 2, 7, 1 ]
|
|
1822
1835
|
* refers to:
|
|
@@ -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.8.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.8.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";
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { Message } from "../../message.js";
|
|
15
15
|
import { proto3 } from "../../proto3.js";
|
|
16
|
-
import { ScalarType } from "../../
|
|
16
|
+
import { ScalarType } from "../../scalar.js";
|
|
17
17
|
import { protoInt64 } from "../../proto-int64.js";
|
|
18
18
|
/**
|
|
19
19
|
* Wrapper message for `double`.
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ export { protoDelimited } from "./proto-delimited.js";
|
|
|
7
7
|
export { codegenInfo } from "./codegen-info.js";
|
|
8
8
|
export { Message } from "./message.js";
|
|
9
9
|
export type { AnyMessage, PartialMessage, PlainMessage } from "./message.js";
|
|
10
|
+
export { isMessage } from "./is-message.js";
|
|
10
11
|
export type { FieldInfo } from "./field.js";
|
|
11
12
|
export type { FieldList } from "./field-list.js";
|
|
12
|
-
export {
|
|
13
|
+
export { LongType, ScalarType } from "./scalar.js";
|
|
14
|
+
export type { ScalarValue } from "./scalar.js";
|
|
13
15
|
export type { MessageType } from "./message-type.js";
|
|
14
16
|
export type { EnumType, EnumValueInfo } from "./enum.js";
|
|
15
17
|
export type { Extension } from "./extension.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -19,7 +19,8 @@ export { protoBase64 } from "./proto-base64.js";
|
|
|
19
19
|
export { protoDelimited } from "./proto-delimited.js";
|
|
20
20
|
export { codegenInfo } from "./codegen-info.js";
|
|
21
21
|
export { Message } from "./message.js";
|
|
22
|
-
export {
|
|
22
|
+
export { isMessage } from "./is-message.js";
|
|
23
|
+
export { LongType, ScalarType } from "./scalar.js";
|
|
23
24
|
export { getExtension, setExtension, hasExtension, clearExtension, } from "./extension-accessor.js";
|
|
24
25
|
export { MethodKind, MethodIdempotency } from "./service-type.js";
|
|
25
26
|
export { WireType, BinaryWriter, BinaryReader } from "./binary-encoding.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MessageType } from "./message-type.js";
|
|
2
|
+
import type { AnyMessage } from "./message.js";
|
|
3
|
+
import { Message } from "./message.js";
|
|
4
|
+
/**
|
|
5
|
+
* Check whether the given object is any subtype of Message or is a specific
|
|
6
|
+
* Message by passing the type.
|
|
7
|
+
*
|
|
8
|
+
* Just like `instanceof`, `isMessage` narrows the type. The advantage of
|
|
9
|
+
* `isMessage` is that it compares identity by the message type name, not by
|
|
10
|
+
* class identity. This makes it robust against the dual package hazard and
|
|
11
|
+
* similar situations, where the same message is duplicated.
|
|
12
|
+
*
|
|
13
|
+
* This function is _mostly_ equivalent to the `instanceof` operator. For
|
|
14
|
+
* example, `isMessage(foo, MyMessage)` is the same as `foo instanceof MyMessage`,
|
|
15
|
+
* and `isMessage(foo)` is the same as `foo instanceof Message`. In most cases,
|
|
16
|
+
* `isMessage` should be preferred over `instanceof`.
|
|
17
|
+
*
|
|
18
|
+
* However, due to the fact that `isMessage` does not use class identity, there
|
|
19
|
+
* are subtle differences between this function and `instanceof`. Notably,
|
|
20
|
+
* calling `isMessage` on an explicit type of Message will return false.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isMessage<T extends Message<T> = AnyMessage>(arg: unknown, type?: MessageType<T>): arg is T;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright 2021-2024 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 { Message } from "./message.js";
|
|
15
|
+
/**
|
|
16
|
+
* Check whether the given object is any subtype of Message or is a specific
|
|
17
|
+
* Message by passing the type.
|
|
18
|
+
*
|
|
19
|
+
* Just like `instanceof`, `isMessage` narrows the type. The advantage of
|
|
20
|
+
* `isMessage` is that it compares identity by the message type name, not by
|
|
21
|
+
* class identity. This makes it robust against the dual package hazard and
|
|
22
|
+
* similar situations, where the same message is duplicated.
|
|
23
|
+
*
|
|
24
|
+
* This function is _mostly_ equivalent to the `instanceof` operator. For
|
|
25
|
+
* example, `isMessage(foo, MyMessage)` is the same as `foo instanceof MyMessage`,
|
|
26
|
+
* and `isMessage(foo)` is the same as `foo instanceof Message`. In most cases,
|
|
27
|
+
* `isMessage` should be preferred over `instanceof`.
|
|
28
|
+
*
|
|
29
|
+
* However, due to the fact that `isMessage` does not use class identity, there
|
|
30
|
+
* are subtle differences between this function and `instanceof`. Notably,
|
|
31
|
+
* calling `isMessage` on an explicit type of Message will return false.
|
|
32
|
+
*/
|
|
33
|
+
export function isMessage(arg, type) {
|
|
34
|
+
if (arg === null || typeof arg != "object") {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (!Object.getOwnPropertyNames(Message.prototype).every((m) => m in arg && typeof arg[m] == "function")) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const actualType = arg.getType();
|
|
41
|
+
if (actualType === null ||
|
|
42
|
+
typeof actualType != "function" ||
|
|
43
|
+
!("typeName" in actualType) ||
|
|
44
|
+
typeof actualType.typeName != "string") {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return type === undefined ? true : actualType.typeName == type.typeName;
|
|
48
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Message } from "./message.js";
|
|
2
2
|
import type { MessageType } from "./message-type.js";
|
|
3
|
-
import type { ScalarType } from "./
|
|
4
|
-
import { LongType } from "./field.js";
|
|
3
|
+
import type { ScalarType, LongType } from "./scalar.js";
|
|
5
4
|
import type { IExtensionRegistry, IMessageTypeRegistry } from "./type-registry.js";
|
|
6
5
|
/**
|
|
7
6
|
* JsonFormat is the contract for serializing messages to and from JSON.
|
package/dist/esm/json-format.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IBinaryWriter } from "../binary-encoding.js";
|
|
2
|
+
import type { BinaryFormat, BinaryWriteOptions } from "../binary-format.js";
|
|
3
|
+
import type { FieldInfo } from "../field.js";
|
|
4
|
+
export declare function makeBinaryFormat(): BinaryFormat;
|
|
5
|
+
export declare function writeMapEntry(writer: IBinaryWriter, options: BinaryWriteOptions, field: FieldInfo & {
|
|
6
|
+
kind: "map";
|
|
7
|
+
}, key: string, value: any): void;
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { BinaryReader, BinaryWriter, WireType } from "../binary-encoding.js";
|
|
15
15
|
import { Message } from "../message.js";
|
|
16
|
-
import { LongType, ScalarType } from "../field.js";
|
|
17
16
|
import { wrapField } from "./field-wrapper.js";
|
|
18
|
-
import {
|
|
17
|
+
import { scalarZeroValue } from "./scalars.js";
|
|
19
18
|
import { assert } from "./assert.js";
|
|
20
|
-
|
|
19
|
+
import { isFieldSet } from "./reflect.js";
|
|
20
|
+
import { LongType, ScalarType } from "../scalar.js";
|
|
21
|
+
import { isMessage } from "../is-message.js";
|
|
22
|
+
/* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return */
|
|
21
23
|
const unknownFieldsSymbol = Symbol("@bufbuild/protobuf/unknown-fields");
|
|
22
24
|
// Default options for parsing binary data.
|
|
23
25
|
const readDefaults = {
|
|
@@ -35,7 +37,7 @@ function makeReadOptions(options) {
|
|
|
35
37
|
function makeWriteOptions(options) {
|
|
36
38
|
return options ? Object.assign(Object.assign({}, writeDefaults), options) : writeDefaults;
|
|
37
39
|
}
|
|
38
|
-
export function
|
|
40
|
+
export function makeBinaryFormat() {
|
|
39
41
|
return {
|
|
40
42
|
makeReadOptions,
|
|
41
43
|
makeWriteOptions,
|
|
@@ -90,6 +92,35 @@ export function makeBinaryFormatCommon() {
|
|
|
90
92
|
}
|
|
91
93
|
},
|
|
92
94
|
readField,
|
|
95
|
+
writeMessage(message, writer, options) {
|
|
96
|
+
const type = message.getType();
|
|
97
|
+
for (const field of type.fields.byNumber()) {
|
|
98
|
+
if (!isFieldSet(field, message)) {
|
|
99
|
+
if (field.req) {
|
|
100
|
+
throw new Error(`cannot encode field ${type.typeName}.${field.name} to binary: required field not set`);
|
|
101
|
+
}
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const value = field.oneof
|
|
105
|
+
? message[field.oneof.localName].value
|
|
106
|
+
: message[field.localName];
|
|
107
|
+
writeField(field, value, writer, options);
|
|
108
|
+
}
|
|
109
|
+
if (options.writeUnknownFields) {
|
|
110
|
+
this.writeUnknownFields(message, writer);
|
|
111
|
+
}
|
|
112
|
+
return writer;
|
|
113
|
+
},
|
|
114
|
+
writeField(field, value, writer, options) {
|
|
115
|
+
// The behavior of our internal function has changed, it does no longer
|
|
116
|
+
// accept `undefined` values for singular scalar and map.
|
|
117
|
+
// For backwards-compatibility, we support the old form that is part of
|
|
118
|
+
// the public API through the interface BinaryFormat.
|
|
119
|
+
if (value === undefined) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
writeField(field, value, writer, options);
|
|
123
|
+
},
|
|
93
124
|
};
|
|
94
125
|
}
|
|
95
126
|
function readField(target, // eslint-disable-line @typescript-eslint/no-explicit-any -- `any` is the best choice for dynamic access
|
|
@@ -138,7 +169,7 @@ reader, field, wireType, options) {
|
|
|
138
169
|
target[localName].push(readMessageField(reader, new messageType(), options, field));
|
|
139
170
|
}
|
|
140
171
|
else {
|
|
141
|
-
if (target[localName]
|
|
172
|
+
if (isMessage(target[localName])) {
|
|
142
173
|
readMessageField(reader, target[localName], options, field);
|
|
143
174
|
}
|
|
144
175
|
else {
|
|
@@ -161,7 +192,7 @@ reader, field, wireType, options) {
|
|
|
161
192
|
function readMessageField(reader, message, options, field) {
|
|
162
193
|
const format = message.getType().runtime.bin;
|
|
163
194
|
const delimited = field === null || field === void 0 ? void 0 : field.delimited;
|
|
164
|
-
format.readMessage(message, reader, delimited ? field
|
|
195
|
+
format.readMessage(message, reader, delimited ? field.no : reader.uint32(), // eslint-disable-line @typescript-eslint/strict-boolean-expressions
|
|
165
196
|
options, delimited);
|
|
166
197
|
return message;
|
|
167
198
|
}
|
|
@@ -170,7 +201,7 @@ function readMapEntry(field, reader, options) {
|
|
|
170
201
|
const length = reader.uint32(), end = reader.pos + length;
|
|
171
202
|
let key, val;
|
|
172
203
|
while (reader.pos < end) {
|
|
173
|
-
|
|
204
|
+
const [fieldNo] = reader.tag();
|
|
174
205
|
switch (fieldNo) {
|
|
175
206
|
case 1:
|
|
176
207
|
key = readScalar(reader, field.K);
|
|
@@ -191,11 +222,7 @@ function readMapEntry(field, reader, options) {
|
|
|
191
222
|
}
|
|
192
223
|
}
|
|
193
224
|
if (key === undefined) {
|
|
194
|
-
|
|
195
|
-
key =
|
|
196
|
-
field.K == ScalarType.BOOL
|
|
197
|
-
? keyRaw.toString()
|
|
198
|
-
: keyRaw;
|
|
225
|
+
key = scalarZeroValue(field.K, LongType.BIGINT);
|
|
199
226
|
}
|
|
200
227
|
if (typeof key != "string" && typeof key != "number") {
|
|
201
228
|
key = key.toString();
|
|
@@ -203,10 +230,10 @@ function readMapEntry(field, reader, options) {
|
|
|
203
230
|
if (val === undefined) {
|
|
204
231
|
switch (field.V.kind) {
|
|
205
232
|
case "scalar":
|
|
206
|
-
val =
|
|
233
|
+
val = scalarZeroValue(field.V.T, LongType.BIGINT);
|
|
207
234
|
break;
|
|
208
235
|
case "enum":
|
|
209
|
-
val = 0;
|
|
236
|
+
val = field.V.T.values[0].no;
|
|
210
237
|
break;
|
|
211
238
|
case "message":
|
|
212
239
|
val = new field.V.T();
|
|
@@ -256,6 +283,47 @@ function readScalar(reader, type) {
|
|
|
256
283
|
return reader.sint32();
|
|
257
284
|
}
|
|
258
285
|
}
|
|
286
|
+
function writeField(field, value, writer, options) {
|
|
287
|
+
assert(value !== undefined);
|
|
288
|
+
const repeated = field.repeated;
|
|
289
|
+
switch (field.kind) {
|
|
290
|
+
case "scalar":
|
|
291
|
+
case "enum":
|
|
292
|
+
let scalarType = field.kind == "enum" ? ScalarType.INT32 : field.T;
|
|
293
|
+
if (repeated) {
|
|
294
|
+
assert(Array.isArray(value));
|
|
295
|
+
if (field.packed) {
|
|
296
|
+
writePacked(writer, scalarType, field.no, value);
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
for (const item of value) {
|
|
300
|
+
writeScalar(writer, scalarType, field.no, item);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
writeScalar(writer, scalarType, field.no, value);
|
|
306
|
+
}
|
|
307
|
+
break;
|
|
308
|
+
case "message":
|
|
309
|
+
if (repeated) {
|
|
310
|
+
assert(Array.isArray(value));
|
|
311
|
+
for (const item of value) {
|
|
312
|
+
writeMessageField(writer, options, field, item);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
writeMessageField(writer, options, field, value);
|
|
317
|
+
}
|
|
318
|
+
break;
|
|
319
|
+
case "map":
|
|
320
|
+
assert(typeof value == "object" && value != null);
|
|
321
|
+
for (const [key, val] of Object.entries(value)) {
|
|
322
|
+
writeMapEntry(writer, options, field, key, val);
|
|
323
|
+
}
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
259
327
|
export function writeMapEntry(writer, options, field, key, value) {
|
|
260
328
|
writer.tag(field.no, WireType.LengthDelimited);
|
|
261
329
|
writer.fork();
|
|
@@ -277,26 +345,27 @@ export function writeMapEntry(writer, options, field, key, value) {
|
|
|
277
345
|
break;
|
|
278
346
|
}
|
|
279
347
|
// write key, expecting key field number = 1
|
|
280
|
-
writeScalar(writer, field.K, 1, keyValue
|
|
348
|
+
writeScalar(writer, field.K, 1, keyValue);
|
|
281
349
|
// write value, expecting value field number = 2
|
|
282
350
|
switch (field.V.kind) {
|
|
283
351
|
case "scalar":
|
|
284
|
-
writeScalar(writer, field.V.T, 2, value
|
|
352
|
+
writeScalar(writer, field.V.T, 2, value);
|
|
285
353
|
break;
|
|
286
354
|
case "enum":
|
|
287
|
-
writeScalar(writer, ScalarType.INT32, 2, value
|
|
355
|
+
writeScalar(writer, ScalarType.INT32, 2, value);
|
|
288
356
|
break;
|
|
289
357
|
case "message":
|
|
358
|
+
assert(value !== undefined);
|
|
290
359
|
writer.tag(2, WireType.LengthDelimited).bytes(value.toBinary(options));
|
|
291
360
|
break;
|
|
292
361
|
}
|
|
293
362
|
writer.join();
|
|
294
363
|
}
|
|
295
364
|
// Value must not be undefined
|
|
296
|
-
|
|
365
|
+
function writeMessageField(writer, options, field, value) {
|
|
297
366
|
const message = wrapField(field.T, value);
|
|
298
367
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
299
|
-
if (field
|
|
368
|
+
if (field.delimited)
|
|
300
369
|
writer
|
|
301
370
|
.tag(field.no, WireType.StartGroup)
|
|
302
371
|
.raw(message.toBinary(options))
|
|
@@ -306,13 +375,12 @@ export function writeMessageField(writer, options, field, value) {
|
|
|
306
375
|
.tag(field.no, WireType.LengthDelimited)
|
|
307
376
|
.bytes(message.toBinary(options));
|
|
308
377
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
378
|
+
function writeScalar(writer, type, fieldNo, value) {
|
|
379
|
+
assert(value !== undefined);
|
|
380
|
+
let [wireType, method] = scalarTypeInfo(type);
|
|
381
|
+
writer.tag(fieldNo, wireType)[method](value);
|
|
314
382
|
}
|
|
315
|
-
|
|
383
|
+
function writePacked(writer, type, fieldNo, value) {
|
|
316
384
|
if (!value.length) {
|
|
317
385
|
return;
|
|
318
386
|
}
|
|
@@ -323,3 +391,36 @@ export function writePacked(writer, type, fieldNo, value) {
|
|
|
323
391
|
}
|
|
324
392
|
writer.join();
|
|
325
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Get information for writing a scalar value.
|
|
396
|
+
*
|
|
397
|
+
* Returns tuple:
|
|
398
|
+
* [0]: appropriate WireType
|
|
399
|
+
* [1]: name of the appropriate method of IBinaryWriter
|
|
400
|
+
* [2]: whether the given value is a default value for proto3 semantics
|
|
401
|
+
*
|
|
402
|
+
* If argument `value` is omitted, [2] is always false.
|
|
403
|
+
*/
|
|
404
|
+
// TODO replace call-sites writeScalar() and writePacked(), then remove
|
|
405
|
+
function scalarTypeInfo(type) {
|
|
406
|
+
let wireType = WireType.Varint;
|
|
407
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- INT32, UINT32, SINT32 are covered by the defaults
|
|
408
|
+
switch (type) {
|
|
409
|
+
case ScalarType.BYTES:
|
|
410
|
+
case ScalarType.STRING:
|
|
411
|
+
wireType = WireType.LengthDelimited;
|
|
412
|
+
break;
|
|
413
|
+
case ScalarType.DOUBLE:
|
|
414
|
+
case ScalarType.FIXED64:
|
|
415
|
+
case ScalarType.SFIXED64:
|
|
416
|
+
wireType = WireType.Bit64;
|
|
417
|
+
break;
|
|
418
|
+
case ScalarType.FIXED32:
|
|
419
|
+
case ScalarType.SFIXED32:
|
|
420
|
+
case ScalarType.FLOAT:
|
|
421
|
+
wireType = WireType.Bit32;
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
const method = ScalarType[type].toLowerCase();
|
|
425
|
+
return [wireType, method];
|
|
426
|
+
}
|
|
@@ -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
|
-
import {
|
|
14
|
+
import { scalarZeroValue } from "./scalars.js";
|
|
15
15
|
import { WireType } from "../binary-encoding.js";
|
|
16
16
|
/**
|
|
17
17
|
* Create a new extension using the given runtime.
|
|
@@ -55,7 +55,7 @@ function initExtensionField(ext) {
|
|
|
55
55
|
case "enum":
|
|
56
56
|
return field.T.values[0].no;
|
|
57
57
|
case "scalar":
|
|
58
|
-
return
|
|
58
|
+
return scalarZeroValue(field.T, field.L);
|
|
59
59
|
case "message":
|
|
60
60
|
// eslint-disable-next-line no-case-declarations
|
|
61
61
|
const T = field.T, value = new T();
|