@aptre/protobuf-es-lite 0.2.15 → 0.3.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.
Files changed (36) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +10 -15
  3. package/dist/binary.d.ts +13 -10
  4. package/dist/binary.js +24 -23
  5. package/dist/codegen-info.d.ts +8 -0
  6. package/dist/codegen-info.js +12 -4
  7. package/dist/descriptor-set.d.ts +8 -9
  8. package/dist/google/protobuf/any.pb.d.ts +55 -2
  9. package/dist/google/protobuf/any.pb.js +74 -4
  10. package/dist/google/protobuf/api.pb.js +13 -10
  11. package/dist/google/protobuf/descriptor.pb.js +125 -93
  12. package/dist/google/protobuf/duration.pb.d.ts +7 -2
  13. package/dist/google/protobuf/duration.pb.js +54 -4
  14. package/dist/google/protobuf/empty.pb.js +1 -0
  15. package/dist/google/protobuf/source_context.pb.js +3 -2
  16. package/dist/google/protobuf/struct.pb.d.ts +17 -4
  17. package/dist/google/protobuf/struct.pb.js +104 -8
  18. package/dist/google/protobuf/timestamp.pb.d.ts +8 -2
  19. package/dist/google/protobuf/timestamp.pb.js +54 -4
  20. package/dist/google/protobuf/type.pb.js +21 -16
  21. package/dist/google/protobuf/wrappers.pb.d.ts +47 -10
  22. package/dist/google/protobuf/wrappers.pb.js +190 -19
  23. package/dist/index.d.ts +5 -1
  24. package/dist/index.js +4 -1
  25. package/dist/json.d.ts +30 -4
  26. package/dist/json.js +17 -16
  27. package/dist/message.d.ts +5 -12
  28. package/dist/message.js +75 -77
  29. package/dist/protoc-gen-es-lite/typescript.d.ts +2 -2
  30. package/dist/protoc-gen-es-lite/typescript.js +323 -26
  31. package/dist/protoplugin/ecmascript/reify-wkt.d.ts +1 -5
  32. package/dist/protoplugin/ecmascript/reify-wkt.js +0 -10
  33. package/dist/type-registry.d.ts +43 -0
  34. package/dist/type-registry.js +14 -0
  35. package/example/example.pb.ts +6 -7
  36. package/package.json +3 -1
@@ -27,7 +27,7 @@
27
27
  // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
28
  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
29
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
- import { createEnumType, createMessageType } from "../../index.js";
30
+ import { createEnumType, createMessageType, ScalarType } from "../../index.js";
31
31
  export const protobufPackage = "google.protobuf";
32
32
  /**
33
33
  * The full set of known editions.
@@ -691,14 +691,16 @@ export const GeneratedCodeInfo_Annotation_Semantic_Enum = createEnumType("google
691
691
  { no: 1, name: "SET" },
692
692
  { no: 2, name: "ALIAS" },
693
693
  ]);
694
+ // FieldOptions_EditionDefault contains the message type declaration for FieldOptions_EditionDefault.
694
695
  export const FieldOptions_EditionDefault = createMessageType({
695
696
  typeName: "google.protobuf.FieldOptions.EditionDefault",
696
697
  fields: [
697
698
  { no: 3, name: "edition", kind: "enum", T: Edition_Enum, opt: true },
698
- { no: 2, name: "value", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
699
+ { no: 2, name: "value", kind: "scalar", T: ScalarType.STRING, opt: true },
699
700
  ],
700
701
  packedByDefault: false,
701
702
  });
703
+ // FeatureSet contains the message type declaration for FeatureSet.
702
704
  export const FeatureSet = createMessageType({
703
705
  typeName: "google.protobuf.FeatureSet",
704
706
  fields: [
@@ -711,38 +713,41 @@ export const FeatureSet = createMessageType({
711
713
  ],
712
714
  packedByDefault: false,
713
715
  });
716
+ // UninterpretedOption_NamePart contains the message type declaration for UninterpretedOption_NamePart.
714
717
  export const UninterpretedOption_NamePart = createMessageType({
715
718
  typeName: "google.protobuf.UninterpretedOption.NamePart",
716
719
  fields: [
717
- { no: 1, name: "name_part", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true },
718
- { no: 2, name: "is_extension", kind: "scalar", T: 8 /* ScalarType.BOOL */, req: true },
720
+ { no: 1, name: "name_part", kind: "scalar", T: ScalarType.STRING, req: true },
721
+ { no: 2, name: "is_extension", kind: "scalar", T: ScalarType.BOOL, req: true },
719
722
  ],
720
723
  packedByDefault: false,
721
724
  });
725
+ // UninterpretedOption contains the message type declaration for UninterpretedOption.
722
726
  export const UninterpretedOption = createMessageType({
723
727
  typeName: "google.protobuf.UninterpretedOption",
724
728
  fields: [
725
729
  { no: 2, name: "name", kind: "message", T: () => UninterpretedOption_NamePart, repeated: true },
726
- { no: 3, name: "identifier_value", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
727
- { no: 4, name: "positive_int_value", kind: "scalar", T: 4 /* ScalarType.UINT64 */, opt: true },
728
- { no: 5, name: "negative_int_value", kind: "scalar", T: 3 /* ScalarType.INT64 */, opt: true },
729
- { no: 6, name: "double_value", kind: "scalar", T: 1 /* ScalarType.DOUBLE */, opt: true },
730
- { no: 7, name: "string_value", kind: "scalar", T: 12 /* ScalarType.BYTES */, opt: true },
731
- { no: 8, name: "aggregate_value", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
730
+ { no: 3, name: "identifier_value", kind: "scalar", T: ScalarType.STRING, opt: true },
731
+ { no: 4, name: "positive_int_value", kind: "scalar", T: ScalarType.UINT64, opt: true },
732
+ { no: 5, name: "negative_int_value", kind: "scalar", T: ScalarType.INT64, opt: true },
733
+ { no: 6, name: "double_value", kind: "scalar", T: ScalarType.DOUBLE, opt: true },
734
+ { no: 7, name: "string_value", kind: "scalar", T: ScalarType.BYTES, opt: true },
735
+ { no: 8, name: "aggregate_value", kind: "scalar", T: ScalarType.STRING, opt: true },
732
736
  ],
733
737
  packedByDefault: false,
734
738
  });
739
+ // FieldOptions contains the message type declaration for FieldOptions.
735
740
  export const FieldOptions = createMessageType({
736
741
  typeName: "google.protobuf.FieldOptions",
737
742
  fields: [
738
743
  { no: 1, name: "ctype", kind: "enum", T: FieldOptions_CType_Enum, opt: true, default: FieldOptions_CType.STRING },
739
- { no: 2, name: "packed", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
744
+ { no: 2, name: "packed", kind: "scalar", T: ScalarType.BOOL, opt: true },
740
745
  { no: 6, name: "jstype", kind: "enum", T: FieldOptions_JSType_Enum, opt: true, default: FieldOptions_JSType.JS_NORMAL },
741
- { no: 5, name: "lazy", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
742
- { no: 15, name: "unverified_lazy", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
743
- { no: 3, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
744
- { no: 10, name: "weak", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
745
- { no: 16, name: "debug_redact", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
746
+ { no: 5, name: "lazy", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
747
+ { no: 15, name: "unverified_lazy", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
748
+ { no: 3, name: "deprecated", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
749
+ { no: 10, name: "weak", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
750
+ { no: 16, name: "debug_redact", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
746
751
  { no: 17, name: "retention", kind: "enum", T: FieldOptions_OptionRetention_Enum, opt: true },
747
752
  { no: 19, name: "targets", kind: "enum", T: FieldOptions_OptionTargetType_Enum, repeated: true },
748
753
  { no: 20, name: "edition_defaults", kind: "message", T: () => FieldOptions_EditionDefault, repeated: true },
@@ -751,83 +756,91 @@ export const FieldOptions = createMessageType({
751
756
  ],
752
757
  packedByDefault: false,
753
758
  });
759
+ // FieldDescriptorProto contains the message type declaration for FieldDescriptorProto.
754
760
  export const FieldDescriptorProto = createMessageType({
755
761
  typeName: "google.protobuf.FieldDescriptorProto",
756
762
  fields: [
757
- { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
758
- { no: 3, name: "number", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
763
+ { no: 1, name: "name", kind: "scalar", T: ScalarType.STRING, opt: true },
764
+ { no: 3, name: "number", kind: "scalar", T: ScalarType.INT32, opt: true },
759
765
  { no: 4, name: "label", kind: "enum", T: FieldDescriptorProto_Label_Enum, opt: true },
760
766
  { no: 5, name: "type", kind: "enum", T: FieldDescriptorProto_Type_Enum, opt: true },
761
- { no: 6, name: "type_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
762
- { no: 2, name: "extendee", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
763
- { no: 7, name: "default_value", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
764
- { no: 9, name: "oneof_index", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
765
- { no: 10, name: "json_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
767
+ { no: 6, name: "type_name", kind: "scalar", T: ScalarType.STRING, opt: true },
768
+ { no: 2, name: "extendee", kind: "scalar", T: ScalarType.STRING, opt: true },
769
+ { no: 7, name: "default_value", kind: "scalar", T: ScalarType.STRING, opt: true },
770
+ { no: 9, name: "oneof_index", kind: "scalar", T: ScalarType.INT32, opt: true },
771
+ { no: 10, name: "json_name", kind: "scalar", T: ScalarType.STRING, opt: true },
766
772
  { no: 8, name: "options", kind: "message", T: () => FieldOptions, opt: true },
767
- { no: 17, name: "proto3_optional", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
773
+ { no: 17, name: "proto3_optional", kind: "scalar", T: ScalarType.BOOL, opt: true },
768
774
  ],
769
775
  packedByDefault: false,
770
776
  });
777
+ // EnumValueOptions contains the message type declaration for EnumValueOptions.
771
778
  export const EnumValueOptions = createMessageType({
772
779
  typeName: "google.protobuf.EnumValueOptions",
773
780
  fields: [
774
- { no: 1, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
781
+ { no: 1, name: "deprecated", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
775
782
  { no: 2, name: "features", kind: "message", T: () => FeatureSet, opt: true },
776
- { no: 3, name: "debug_redact", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
783
+ { no: 3, name: "debug_redact", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
777
784
  { no: 999, name: "uninterpreted_option", kind: "message", T: () => UninterpretedOption, repeated: true },
778
785
  ],
779
786
  packedByDefault: false,
780
787
  });
788
+ // EnumValueDescriptorProto contains the message type declaration for EnumValueDescriptorProto.
781
789
  export const EnumValueDescriptorProto = createMessageType({
782
790
  typeName: "google.protobuf.EnumValueDescriptorProto",
783
791
  fields: [
784
- { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
785
- { no: 2, name: "number", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
792
+ { no: 1, name: "name", kind: "scalar", T: ScalarType.STRING, opt: true },
793
+ { no: 2, name: "number", kind: "scalar", T: ScalarType.INT32, opt: true },
786
794
  { no: 3, name: "options", kind: "message", T: () => EnumValueOptions, opt: true },
787
795
  ],
788
796
  packedByDefault: false,
789
797
  });
798
+ // EnumOptions contains the message type declaration for EnumOptions.
790
799
  export const EnumOptions = createMessageType({
791
800
  typeName: "google.protobuf.EnumOptions",
792
801
  fields: [
793
- { no: 2, name: "allow_alias", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
794
- { no: 3, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
795
- { no: 6, name: "deprecated_legacy_json_field_conflicts", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
802
+ { no: 2, name: "allow_alias", kind: "scalar", T: ScalarType.BOOL, opt: true },
803
+ { no: 3, name: "deprecated", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
804
+ { no: 6, name: "deprecated_legacy_json_field_conflicts", kind: "scalar", T: ScalarType.BOOL, opt: true },
796
805
  { no: 7, name: "features", kind: "message", T: () => FeatureSet, opt: true },
797
806
  { no: 999, name: "uninterpreted_option", kind: "message", T: () => UninterpretedOption, repeated: true },
798
807
  ],
799
808
  packedByDefault: false,
800
809
  });
810
+ // EnumDescriptorProto_EnumReservedRange contains the message type declaration for EnumDescriptorProto_EnumReservedRange.
801
811
  export const EnumDescriptorProto_EnumReservedRange = createMessageType({
802
812
  typeName: "google.protobuf.EnumDescriptorProto.EnumReservedRange",
803
813
  fields: [
804
- { no: 1, name: "start", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
805
- { no: 2, name: "end", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
814
+ { no: 1, name: "start", kind: "scalar", T: ScalarType.INT32, opt: true },
815
+ { no: 2, name: "end", kind: "scalar", T: ScalarType.INT32, opt: true },
806
816
  ],
807
817
  packedByDefault: false,
808
818
  });
819
+ // EnumDescriptorProto contains the message type declaration for EnumDescriptorProto.
809
820
  export const EnumDescriptorProto = createMessageType({
810
821
  typeName: "google.protobuf.EnumDescriptorProto",
811
822
  fields: [
812
- { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
823
+ { no: 1, name: "name", kind: "scalar", T: ScalarType.STRING, opt: true },
813
824
  { no: 2, name: "value", kind: "message", T: () => EnumValueDescriptorProto, repeated: true },
814
825
  { no: 3, name: "options", kind: "message", T: () => EnumOptions, opt: true },
815
826
  { no: 4, name: "reserved_range", kind: "message", T: () => EnumDescriptorProto_EnumReservedRange, repeated: true },
816
- { no: 5, name: "reserved_name", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
827
+ { no: 5, name: "reserved_name", kind: "scalar", T: ScalarType.STRING, repeated: true },
817
828
  ],
818
829
  packedByDefault: false,
819
830
  });
831
+ // ExtensionRangeOptions_Declaration contains the message type declaration for ExtensionRangeOptions_Declaration.
820
832
  export const ExtensionRangeOptions_Declaration = createMessageType({
821
833
  typeName: "google.protobuf.ExtensionRangeOptions.Declaration",
822
834
  fields: [
823
- { no: 1, name: "number", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
824
- { no: 2, name: "full_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
825
- { no: 3, name: "type", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
826
- { no: 5, name: "reserved", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
827
- { no: 6, name: "repeated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
835
+ { no: 1, name: "number", kind: "scalar", T: ScalarType.INT32, opt: true },
836
+ { no: 2, name: "full_name", kind: "scalar", T: ScalarType.STRING, opt: true },
837
+ { no: 3, name: "type", kind: "scalar", T: ScalarType.STRING, opt: true },
838
+ { no: 5, name: "reserved", kind: "scalar", T: ScalarType.BOOL, opt: true },
839
+ { no: 6, name: "repeated", kind: "scalar", T: ScalarType.BOOL, opt: true },
828
840
  ],
829
841
  packedByDefault: false,
830
842
  });
843
+ // ExtensionRangeOptions contains the message type declaration for ExtensionRangeOptions.
831
844
  export const ExtensionRangeOptions = createMessageType({
832
845
  typeName: "google.protobuf.ExtensionRangeOptions",
833
846
  fields: [
@@ -838,15 +851,17 @@ export const ExtensionRangeOptions = createMessageType({
838
851
  ],
839
852
  packedByDefault: false,
840
853
  });
854
+ // DescriptorProto_ExtensionRange contains the message type declaration for DescriptorProto_ExtensionRange.
841
855
  export const DescriptorProto_ExtensionRange = createMessageType({
842
856
  typeName: "google.protobuf.DescriptorProto.ExtensionRange",
843
857
  fields: [
844
- { no: 1, name: "start", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
845
- { no: 2, name: "end", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
858
+ { no: 1, name: "start", kind: "scalar", T: ScalarType.INT32, opt: true },
859
+ { no: 2, name: "end", kind: "scalar", T: ScalarType.INT32, opt: true },
846
860
  { no: 3, name: "options", kind: "message", T: () => ExtensionRangeOptions, opt: true },
847
861
  ],
848
862
  packedByDefault: false,
849
863
  });
864
+ // OneofOptions contains the message type declaration for OneofOptions.
850
865
  export const OneofOptions = createMessageType({
851
866
  typeName: "google.protobuf.OneofOptions",
852
867
  fields: [
@@ -855,39 +870,43 @@ export const OneofOptions = createMessageType({
855
870
  ],
856
871
  packedByDefault: false,
857
872
  });
873
+ // OneofDescriptorProto contains the message type declaration for OneofDescriptorProto.
858
874
  export const OneofDescriptorProto = createMessageType({
859
875
  typeName: "google.protobuf.OneofDescriptorProto",
860
876
  fields: [
861
- { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
877
+ { no: 1, name: "name", kind: "scalar", T: ScalarType.STRING, opt: true },
862
878
  { no: 2, name: "options", kind: "message", T: () => OneofOptions, opt: true },
863
879
  ],
864
880
  packedByDefault: false,
865
881
  });
882
+ // MessageOptions contains the message type declaration for MessageOptions.
866
883
  export const MessageOptions = createMessageType({
867
884
  typeName: "google.protobuf.MessageOptions",
868
885
  fields: [
869
- { no: 1, name: "message_set_wire_format", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
870
- { no: 2, name: "no_standard_descriptor_accessor", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
871
- { no: 3, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
872
- { no: 7, name: "map_entry", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
873
- { no: 11, name: "deprecated_legacy_json_field_conflicts", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
886
+ { no: 1, name: "message_set_wire_format", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
887
+ { no: 2, name: "no_standard_descriptor_accessor", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
888
+ { no: 3, name: "deprecated", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
889
+ { no: 7, name: "map_entry", kind: "scalar", T: ScalarType.BOOL, opt: true },
890
+ { no: 11, name: "deprecated_legacy_json_field_conflicts", kind: "scalar", T: ScalarType.BOOL, opt: true },
874
891
  { no: 12, name: "features", kind: "message", T: () => FeatureSet, opt: true },
875
892
  { no: 999, name: "uninterpreted_option", kind: "message", T: () => UninterpretedOption, repeated: true },
876
893
  ],
877
894
  packedByDefault: false,
878
895
  });
896
+ // DescriptorProto_ReservedRange contains the message type declaration for DescriptorProto_ReservedRange.
879
897
  export const DescriptorProto_ReservedRange = createMessageType({
880
898
  typeName: "google.protobuf.DescriptorProto.ReservedRange",
881
899
  fields: [
882
- { no: 1, name: "start", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
883
- { no: 2, name: "end", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
900
+ { no: 1, name: "start", kind: "scalar", T: ScalarType.INT32, opt: true },
901
+ { no: 2, name: "end", kind: "scalar", T: ScalarType.INT32, opt: true },
884
902
  ],
885
903
  packedByDefault: false,
886
904
  });
905
+ // DescriptorProto contains the message type declaration for DescriptorProto.
887
906
  export const DescriptorProto = createMessageType({
888
907
  typeName: "google.protobuf.DescriptorProto",
889
908
  fields: [
890
- { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
909
+ { no: 1, name: "name", kind: "scalar", T: ScalarType.STRING, opt: true },
891
910
  { no: 2, name: "field", kind: "message", T: () => FieldDescriptorProto, repeated: true },
892
911
  { no: 6, name: "extension", kind: "message", T: () => FieldDescriptorProto, repeated: true },
893
912
  { no: 3, name: "nested_type", kind: "message", T: () => DescriptorProto, repeated: true },
@@ -896,88 +915,95 @@ export const DescriptorProto = createMessageType({
896
915
  { no: 8, name: "oneof_decl", kind: "message", T: () => OneofDescriptorProto, repeated: true },
897
916
  { no: 7, name: "options", kind: "message", T: () => MessageOptions, opt: true },
898
917
  { no: 9, name: "reserved_range", kind: "message", T: () => DescriptorProto_ReservedRange, repeated: true },
899
- { no: 10, name: "reserved_name", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
918
+ { no: 10, name: "reserved_name", kind: "scalar", T: ScalarType.STRING, repeated: true },
900
919
  ],
901
920
  packedByDefault: false,
902
921
  });
922
+ // MethodOptions contains the message type declaration for MethodOptions.
903
923
  export const MethodOptions = createMessageType({
904
924
  typeName: "google.protobuf.MethodOptions",
905
925
  fields: [
906
- { no: 33, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
926
+ { no: 33, name: "deprecated", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
907
927
  { no: 34, name: "idempotency_level", kind: "enum", T: MethodOptions_IdempotencyLevel_Enum, opt: true, default: MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN },
908
928
  { no: 35, name: "features", kind: "message", T: () => FeatureSet, opt: true },
909
929
  { no: 999, name: "uninterpreted_option", kind: "message", T: () => UninterpretedOption, repeated: true },
910
930
  ],
911
931
  packedByDefault: false,
912
932
  });
933
+ // MethodDescriptorProto contains the message type declaration for MethodDescriptorProto.
913
934
  export const MethodDescriptorProto = createMessageType({
914
935
  typeName: "google.protobuf.MethodDescriptorProto",
915
936
  fields: [
916
- { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
917
- { no: 2, name: "input_type", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
918
- { no: 3, name: "output_type", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
937
+ { no: 1, name: "name", kind: "scalar", T: ScalarType.STRING, opt: true },
938
+ { no: 2, name: "input_type", kind: "scalar", T: ScalarType.STRING, opt: true },
939
+ { no: 3, name: "output_type", kind: "scalar", T: ScalarType.STRING, opt: true },
919
940
  { no: 4, name: "options", kind: "message", T: () => MethodOptions, opt: true },
920
- { no: 5, name: "client_streaming", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
921
- { no: 6, name: "server_streaming", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
941
+ { no: 5, name: "client_streaming", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
942
+ { no: 6, name: "server_streaming", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
922
943
  ],
923
944
  packedByDefault: false,
924
945
  });
946
+ // ServiceOptions contains the message type declaration for ServiceOptions.
925
947
  export const ServiceOptions = createMessageType({
926
948
  typeName: "google.protobuf.ServiceOptions",
927
949
  fields: [
928
950
  { no: 34, name: "features", kind: "message", T: () => FeatureSet, opt: true },
929
- { no: 33, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
951
+ { no: 33, name: "deprecated", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
930
952
  { no: 999, name: "uninterpreted_option", kind: "message", T: () => UninterpretedOption, repeated: true },
931
953
  ],
932
954
  packedByDefault: false,
933
955
  });
956
+ // ServiceDescriptorProto contains the message type declaration for ServiceDescriptorProto.
934
957
  export const ServiceDescriptorProto = createMessageType({
935
958
  typeName: "google.protobuf.ServiceDescriptorProto",
936
959
  fields: [
937
- { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
960
+ { no: 1, name: "name", kind: "scalar", T: ScalarType.STRING, opt: true },
938
961
  { no: 2, name: "method", kind: "message", T: () => MethodDescriptorProto, repeated: true },
939
962
  { no: 3, name: "options", kind: "message", T: () => ServiceOptions, opt: true },
940
963
  ],
941
964
  packedByDefault: false,
942
965
  });
966
+ // FileOptions contains the message type declaration for FileOptions.
943
967
  export const FileOptions = createMessageType({
944
968
  typeName: "google.protobuf.FileOptions",
945
969
  fields: [
946
- { no: 1, name: "java_package", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
947
- { no: 8, name: "java_outer_classname", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
948
- { no: 10, name: "java_multiple_files", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
949
- { no: 20, name: "java_generate_equals_and_hash", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
950
- { no: 27, name: "java_string_check_utf8", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
970
+ { no: 1, name: "java_package", kind: "scalar", T: ScalarType.STRING, opt: true },
971
+ { no: 8, name: "java_outer_classname", kind: "scalar", T: ScalarType.STRING, opt: true },
972
+ { no: 10, name: "java_multiple_files", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
973
+ { no: 20, name: "java_generate_equals_and_hash", kind: "scalar", T: ScalarType.BOOL, opt: true },
974
+ { no: 27, name: "java_string_check_utf8", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
951
975
  { no: 9, name: "optimize_for", kind: "enum", T: FileOptions_OptimizeMode_Enum, opt: true, default: FileOptions_OptimizeMode.SPEED },
952
- { no: 11, name: "go_package", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
953
- { no: 16, name: "cc_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
954
- { no: 17, name: "java_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
955
- { no: 18, name: "py_generic_services", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
956
- { no: 23, name: "deprecated", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: false },
957
- { no: 31, name: "cc_enable_arenas", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true, default: true },
958
- { no: 36, name: "objc_class_prefix", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
959
- { no: 37, name: "csharp_namespace", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
960
- { no: 39, name: "swift_prefix", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
961
- { no: 40, name: "php_class_prefix", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
962
- { no: 41, name: "php_namespace", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
963
- { no: 44, name: "php_metadata_namespace", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
964
- { no: 45, name: "ruby_package", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
976
+ { no: 11, name: "go_package", kind: "scalar", T: ScalarType.STRING, opt: true },
977
+ { no: 16, name: "cc_generic_services", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
978
+ { no: 17, name: "java_generic_services", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
979
+ { no: 18, name: "py_generic_services", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
980
+ { no: 23, name: "deprecated", kind: "scalar", T: ScalarType.BOOL, opt: true, default: false },
981
+ { no: 31, name: "cc_enable_arenas", kind: "scalar", T: ScalarType.BOOL, opt: true, default: true },
982
+ { no: 36, name: "objc_class_prefix", kind: "scalar", T: ScalarType.STRING, opt: true },
983
+ { no: 37, name: "csharp_namespace", kind: "scalar", T: ScalarType.STRING, opt: true },
984
+ { no: 39, name: "swift_prefix", kind: "scalar", T: ScalarType.STRING, opt: true },
985
+ { no: 40, name: "php_class_prefix", kind: "scalar", T: ScalarType.STRING, opt: true },
986
+ { no: 41, name: "php_namespace", kind: "scalar", T: ScalarType.STRING, opt: true },
987
+ { no: 44, name: "php_metadata_namespace", kind: "scalar", T: ScalarType.STRING, opt: true },
988
+ { no: 45, name: "ruby_package", kind: "scalar", T: ScalarType.STRING, opt: true },
965
989
  { no: 50, name: "features", kind: "message", T: () => FeatureSet, opt: true },
966
990
  { no: 999, name: "uninterpreted_option", kind: "message", T: () => UninterpretedOption, repeated: true },
967
991
  ],
968
992
  packedByDefault: false,
969
993
  });
994
+ // SourceCodeInfo_Location contains the message type declaration for SourceCodeInfo_Location.
970
995
  export const SourceCodeInfo_Location = createMessageType({
971
996
  typeName: "google.protobuf.SourceCodeInfo.Location",
972
997
  fields: [
973
- { no: 1, name: "path", kind: "scalar", T: 5 /* ScalarType.INT32 */, repeated: true, packed: true },
974
- { no: 2, name: "span", kind: "scalar", T: 5 /* ScalarType.INT32 */, repeated: true, packed: true },
975
- { no: 3, name: "leading_comments", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
976
- { no: 4, name: "trailing_comments", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
977
- { no: 6, name: "leading_detached_comments", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
998
+ { no: 1, name: "path", kind: "scalar", T: ScalarType.INT32, repeated: true, packed: true },
999
+ { no: 2, name: "span", kind: "scalar", T: ScalarType.INT32, repeated: true, packed: true },
1000
+ { no: 3, name: "leading_comments", kind: "scalar", T: ScalarType.STRING, opt: true },
1001
+ { no: 4, name: "trailing_comments", kind: "scalar", T: ScalarType.STRING, opt: true },
1002
+ { no: 6, name: "leading_detached_comments", kind: "scalar", T: ScalarType.STRING, repeated: true },
978
1003
  ],
979
1004
  packedByDefault: false,
980
1005
  });
1006
+ // SourceCodeInfo contains the message type declaration for SourceCodeInfo.
981
1007
  export const SourceCodeInfo = createMessageType({
982
1008
  typeName: "google.protobuf.SourceCodeInfo",
983
1009
  fields: [
@@ -985,25 +1011,27 @@ export const SourceCodeInfo = createMessageType({
985
1011
  ],
986
1012
  packedByDefault: false,
987
1013
  });
1014
+ // FileDescriptorProto contains the message type declaration for FileDescriptorProto.
988
1015
  export const FileDescriptorProto = createMessageType({
989
1016
  typeName: "google.protobuf.FileDescriptorProto",
990
1017
  fields: [
991
- { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
992
- { no: 2, name: "package", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
993
- { no: 3, name: "dependency", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
994
- { no: 10, name: "public_dependency", kind: "scalar", T: 5 /* ScalarType.INT32 */, repeated: true },
995
- { no: 11, name: "weak_dependency", kind: "scalar", T: 5 /* ScalarType.INT32 */, repeated: true },
1018
+ { no: 1, name: "name", kind: "scalar", T: ScalarType.STRING, opt: true },
1019
+ { no: 2, name: "package", kind: "scalar", T: ScalarType.STRING, opt: true },
1020
+ { no: 3, name: "dependency", kind: "scalar", T: ScalarType.STRING, repeated: true },
1021
+ { no: 10, name: "public_dependency", kind: "scalar", T: ScalarType.INT32, repeated: true },
1022
+ { no: 11, name: "weak_dependency", kind: "scalar", T: ScalarType.INT32, repeated: true },
996
1023
  { no: 4, name: "message_type", kind: "message", T: () => DescriptorProto, repeated: true },
997
1024
  { no: 5, name: "enum_type", kind: "message", T: () => EnumDescriptorProto, repeated: true },
998
1025
  { no: 6, name: "service", kind: "message", T: () => ServiceDescriptorProto, repeated: true },
999
1026
  { no: 7, name: "extension", kind: "message", T: () => FieldDescriptorProto, repeated: true },
1000
1027
  { no: 8, name: "options", kind: "message", T: () => FileOptions, opt: true },
1001
1028
  { no: 9, name: "source_code_info", kind: "message", T: () => SourceCodeInfo, opt: true },
1002
- { no: 12, name: "syntax", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
1029
+ { no: 12, name: "syntax", kind: "scalar", T: ScalarType.STRING, opt: true },
1003
1030
  { no: 14, name: "edition", kind: "enum", T: Edition_Enum, opt: true },
1004
1031
  ],
1005
1032
  packedByDefault: false,
1006
1033
  });
1034
+ // FileDescriptorSet contains the message type declaration for FileDescriptorSet.
1007
1035
  export const FileDescriptorSet = createMessageType({
1008
1036
  typeName: "google.protobuf.FileDescriptorSet",
1009
1037
  fields: [
@@ -1011,6 +1039,7 @@ export const FileDescriptorSet = createMessageType({
1011
1039
  ],
1012
1040
  packedByDefault: false,
1013
1041
  });
1042
+ // FeatureSetDefaults_FeatureSetEditionDefault contains the message type declaration for FeatureSetDefaults_FeatureSetEditionDefault.
1014
1043
  export const FeatureSetDefaults_FeatureSetEditionDefault = createMessageType({
1015
1044
  typeName: "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault",
1016
1045
  fields: [
@@ -1019,6 +1048,7 @@ export const FeatureSetDefaults_FeatureSetEditionDefault = createMessageType({
1019
1048
  ],
1020
1049
  packedByDefault: false,
1021
1050
  });
1051
+ // FeatureSetDefaults contains the message type declaration for FeatureSetDefaults.
1022
1052
  export const FeatureSetDefaults = createMessageType({
1023
1053
  typeName: "google.protobuf.FeatureSetDefaults",
1024
1054
  fields: [
@@ -1028,17 +1058,19 @@ export const FeatureSetDefaults = createMessageType({
1028
1058
  ],
1029
1059
  packedByDefault: false,
1030
1060
  });
1061
+ // GeneratedCodeInfo_Annotation contains the message type declaration for GeneratedCodeInfo_Annotation.
1031
1062
  export const GeneratedCodeInfo_Annotation = createMessageType({
1032
1063
  typeName: "google.protobuf.GeneratedCodeInfo.Annotation",
1033
1064
  fields: [
1034
- { no: 1, name: "path", kind: "scalar", T: 5 /* ScalarType.INT32 */, repeated: true, packed: true },
1035
- { no: 2, name: "source_file", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
1036
- { no: 3, name: "begin", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
1037
- { no: 4, name: "end", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true },
1065
+ { no: 1, name: "path", kind: "scalar", T: ScalarType.INT32, repeated: true, packed: true },
1066
+ { no: 2, name: "source_file", kind: "scalar", T: ScalarType.STRING, opt: true },
1067
+ { no: 3, name: "begin", kind: "scalar", T: ScalarType.INT32, opt: true },
1068
+ { no: 4, name: "end", kind: "scalar", T: ScalarType.INT32, opt: true },
1038
1069
  { no: 5, name: "semantic", kind: "enum", T: GeneratedCodeInfo_Annotation_Semantic_Enum, opt: true },
1039
1070
  ],
1040
1071
  packedByDefault: false,
1041
1072
  });
1073
+ // GeneratedCodeInfo contains the message type declaration for GeneratedCodeInfo.
1042
1074
  export const GeneratedCodeInfo = createMessageType({
1043
1075
  typeName: "google.protobuf.GeneratedCodeInfo",
1044
1076
  fields: [
@@ -1,4 +1,4 @@
1
- import type { MessageType } from "../../index.js";
1
+ import type { JsonReadOptions, JsonValue, MessageType } from "../../index.js";
2
2
  import { Message } from "../../index.js";
3
3
  export declare const protobufPackage = "google.protobuf";
4
4
  /**
@@ -86,4 +86,9 @@ export type Duration = Message<{
86
86
  */
87
87
  nanos?: number;
88
88
  }>;
89
- export declare const Duration: MessageType<Duration>;
89
+ declare const Duration_Wkt: {
90
+ fromJson(json: JsonValue | null | undefined, _options?: Partial<JsonReadOptions>): Duration;
91
+ toJson(msg: Duration): JsonValue;
92
+ };
93
+ export declare const Duration: MessageType<Duration> & typeof Duration_Wkt;
94
+ export {};
@@ -27,13 +27,63 @@
27
27
  // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
28
  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
29
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
- import { createMessageType } from "../../index.js";
30
+ import { createMessageType, jsonDebugValue, protoInt64, ScalarType } from "../../index.js";
31
31
  export const protobufPackage = "google.protobuf";
32
+ // Duration_Wkt contains the well-known-type overrides for Duration.
33
+ const Duration_Wkt = {
34
+ fromJson(json, _options) {
35
+ if (typeof json !== "string") {
36
+ throw new Error(`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(json)}`);
37
+ }
38
+ const match = json.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);
39
+ if (match === null) {
40
+ throw new Error(`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(json)}`);
41
+ }
42
+ const longSeconds = Number(match[1]);
43
+ if (longSeconds > 315576000000 || longSeconds < -315576000000) {
44
+ throw new Error(`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(json)}`);
45
+ }
46
+ const msg = {};
47
+ msg.seconds = protoInt64.parse(longSeconds);
48
+ if (typeof match[2] == "string") {
49
+ const nanosStr = match[2] + "0".repeat(9 - match[2].length);
50
+ msg.nanos = parseInt(nanosStr);
51
+ if (longSeconds < 0 || Object.is(longSeconds, -0)) {
52
+ msg.nanos = -msg.nanos;
53
+ }
54
+ }
55
+ return msg;
56
+ },
57
+ toJson(msg) {
58
+ const secs = Number(msg.seconds ?? 0);
59
+ const nanos = Number(msg.nanos ?? 0);
60
+ if (secs > 315576000000 || secs < -315576000000) {
61
+ throw new Error(`cannot encode google.protobuf.Duration to JSON: value out of range`);
62
+ }
63
+ let text = secs.toString();
64
+ if (nanos !== 0) {
65
+ let nanosStr = Math.abs(nanos).toString();
66
+ nanosStr = "0".repeat(9 - nanosStr.length) + nanosStr;
67
+ if (nanosStr.substring(3) === "000000") {
68
+ nanosStr = nanosStr.substring(0, 3);
69
+ }
70
+ else if (nanosStr.substring(6) === "000") {
71
+ nanosStr = nanosStr.substring(0, 6);
72
+ }
73
+ text += "." + nanosStr;
74
+ if (nanos < 0 && secs === 0) {
75
+ text = "-" + text;
76
+ }
77
+ }
78
+ return text + "s";
79
+ },
80
+ };
81
+ // Duration contains the message type declaration for Duration.
32
82
  export const Duration = createMessageType({
33
83
  typeName: "google.protobuf.Duration",
34
84
  fields: [
35
- { no: 1, name: "seconds", kind: "scalar", T: 3 /* ScalarType.INT64 */ },
36
- { no: 2, name: "nanos", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
85
+ { no: 1, name: "seconds", kind: "scalar", T: ScalarType.INT64 },
86
+ { no: 2, name: "nanos", kind: "scalar", T: ScalarType.INT32 },
37
87
  ],
38
88
  packedByDefault: true,
39
- });
89
+ }, Duration_Wkt);
@@ -29,6 +29,7 @@
29
29
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
30
  import { createMessageType } from "../../index.js";
31
31
  export const protobufPackage = "google.protobuf";
32
+ // Empty contains the message type declaration for Empty.
32
33
  export const Empty = createMessageType({
33
34
  typeName: "google.protobuf.Empty",
34
35
  fields: [],
@@ -27,12 +27,13 @@
27
27
  // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
28
  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
29
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
- import { createMessageType } from "../../index.js";
30
+ import { createMessageType, ScalarType } from "../../index.js";
31
31
  export const protobufPackage = "google.protobuf";
32
+ // SourceContext contains the message type declaration for SourceContext.
32
33
  export const SourceContext = createMessageType({
33
34
  typeName: "google.protobuf.SourceContext",
34
35
  fields: [
35
- { no: 1, name: "file_name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
36
+ { no: 1, name: "file_name", kind: "scalar", T: ScalarType.STRING },
36
37
  ],
37
38
  packedByDefault: true,
38
39
  });