@bufbuild/protobuf 1.8.0 → 2.0.0-alpha.1
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/clone.d.ts +6 -0
- package/dist/cjs/clone.js +77 -0
- package/dist/cjs/codegenv1/boot.d.ts +63 -0
- package/dist/cjs/codegenv1/boot.js +102 -0
- package/dist/cjs/codegenv1/embed.d.ts +43 -0
- package/dist/cjs/codegenv1/embed.js +238 -0
- package/dist/cjs/codegenv1/enum.d.ts +17 -0
- package/dist/cjs/codegenv1/enum.js +43 -0
- package/dist/cjs/codegenv1/extension.d.ts +9 -0
- package/dist/cjs/codegenv1/extension.js +29 -0
- package/dist/cjs/codegenv1/file.d.ts +7 -0
- package/dist/cjs/codegenv1/file.js +38 -0
- package/dist/cjs/codegenv1/index.d.ts +9 -0
- package/dist/cjs/codegenv1/index.js +38 -0
- package/dist/cjs/codegenv1/message.d.ts +9 -0
- package/dist/cjs/codegenv1/message.js +25 -0
- package/dist/cjs/codegenv1/restore-json-names.d.ts +2 -0
- package/dist/cjs/codegenv1/restore-json-names.js +27 -0
- package/dist/cjs/codegenv1/service.d.ts +8 -0
- package/dist/cjs/codegenv1/service.js +28 -0
- package/dist/cjs/codegenv1/symbols.d.ts +116 -0
- package/dist/cjs/codegenv1/symbols.js +58 -0
- package/dist/cjs/codegenv1/types.d.ts +19 -0
- package/dist/cjs/codegenv1/types.js +21 -0
- package/dist/cjs/create.d.ts +9 -0
- package/dist/cjs/create.js +242 -0
- package/dist/{esm/descriptor-set.d.ts → cjs/desc-types.d.ts} +144 -242
- package/dist/cjs/equals.d.ts +9 -0
- package/dist/cjs/equals.js +133 -0
- package/dist/cjs/{extension-accessor.d.ts → extensions.d.ts} +11 -7
- package/dist/cjs/extensions.js +138 -0
- package/dist/cjs/fields.d.ts +22 -0
- package/dist/cjs/fields.js +39 -0
- package/dist/cjs/from-binary.d.ts +34 -0
- package/dist/cjs/from-binary.js +221 -0
- package/dist/cjs/from-json.d.ts +48 -0
- package/dist/cjs/from-json.js +614 -0
- package/dist/cjs/index.d.ts +16 -42
- package/dist/cjs/index.js +21 -55
- package/dist/cjs/is-message.d.ts +5 -20
- package/dist/cjs/is-message.js +11 -29
- package/dist/cjs/json-value.d.ts +16 -0
- package/dist/cjs/proto-int64.js +2 -2
- package/dist/cjs/reflect/error.d.ts +9 -0
- package/dist/cjs/reflect/error.js +36 -0
- package/dist/cjs/reflect/guard.d.ts +20 -0
- package/dist/cjs/reflect/guard.js +78 -0
- package/dist/cjs/reflect/index.d.ts +8 -0
- package/dist/cjs/reflect/index.js +41 -0
- package/dist/cjs/reflect/names.d.ts +23 -0
- package/dist/cjs/reflect/names.js +112 -0
- package/dist/cjs/reflect/nested-types.d.ts +2 -0
- package/dist/cjs/reflect/nested-types.js +38 -0
- package/dist/cjs/reflect/reflect-check.d.ts +10 -0
- package/dist/cjs/reflect/reflect-check.js +150 -0
- package/dist/cjs/reflect/reflect-types.d.ts +136 -0
- package/dist/cjs/{extension.js → reflect/reflect-types.js} +1 -0
- package/dist/cjs/reflect/reflect.d.ts +23 -0
- package/dist/cjs/reflect/reflect.js +409 -0
- package/dist/cjs/reflect/registry.d.ts +82 -0
- package/dist/cjs/reflect/registry.js +870 -0
- package/dist/{esm → cjs/reflect}/scalar.d.ts +21 -1
- package/dist/cjs/reflect/scalar.js +298 -0
- package/dist/cjs/reflect/unsafe.d.ts +58 -0
- package/dist/cjs/reflect/unsafe.js +171 -0
- package/dist/cjs/to-binary.d.ts +24 -0
- package/dist/cjs/to-binary.js +194 -0
- package/dist/cjs/to-json.d.ts +50 -0
- package/dist/cjs/to-json.js +384 -0
- package/dist/cjs/types.d.ts +68 -0
- package/dist/cjs/wire/base64-encoding.d.ts +23 -0
- package/dist/cjs/wire/base64-encoding.js +156 -0
- package/dist/cjs/wire/binary-encoding.d.ts +242 -0
- package/dist/cjs/{binary-encoding.js → wire/binary-encoding.js} +11 -10
- package/dist/cjs/wire/index.d.ts +5 -0
- package/dist/cjs/wire/index.js +34 -0
- package/dist/cjs/wire/size-delimited.d.ts +51 -0
- package/dist/cjs/wire/size-delimited.js +154 -0
- package/dist/cjs/wire/text-encoding.d.ts +26 -0
- package/dist/cjs/wire/text-encoding.js +55 -0
- package/dist/cjs/wire/text-format.d.ts +14 -0
- package/dist/cjs/{private → wire}/text-format.js +12 -2
- package/dist/{esm/google → cjs/wire}/varint.d.ts +2 -2
- package/dist/cjs/{google → wire}/varint.js +11 -10
- package/dist/cjs/wkt/any.d.ts +38 -0
- package/dist/cjs/wkt/any.js +76 -0
- package/dist/cjs/{google → wkt/gen/google}/protobuf/any_pb.d.ts +6 -27
- package/dist/cjs/wkt/gen/google/protobuf/any_pb.js +22 -0
- package/dist/cjs/{google → wkt/gen/google}/protobuf/api_pb.d.ts +14 -38
- package/dist/cjs/wkt/gen/google/protobuf/api_pb.js +30 -0
- package/dist/cjs/{google → wkt/gen/google}/protobuf/compiler/plugin_pb.d.ts +47 -77
- package/dist/cjs/wkt/gen/google/protobuf/compiler/plugin_pb.js +55 -0
- package/dist/cjs/{google → wkt/gen/google}/protobuf/descriptor_pb.d.ts +384 -533
- package/dist/cjs/wkt/gen/google/protobuf/descriptor_pb.js +691 -0
- package/dist/{esm → cjs/wkt/gen}/google/protobuf/duration_pb.d.ts +6 -18
- package/dist/cjs/wkt/gen/google/protobuf/duration_pb.js +22 -0
- package/dist/cjs/wkt/gen/google/protobuf/empty_pb.d.ts +17 -0
- package/dist/cjs/wkt/gen/google/protobuf/empty_pb.js +22 -0
- package/dist/{esm → cjs/wkt/gen}/google/protobuf/field_mask_pb.d.ts +6 -18
- package/dist/cjs/{proto-double.js → wkt/gen/google/protobuf/field_mask_pb.js} +7 -14
- package/dist/cjs/wkt/gen/google/protobuf/source_context_pb.d.ts +19 -0
- package/dist/cjs/wkt/gen/google/protobuf/source_context_pb.js +22 -0
- package/dist/{esm → cjs/wkt/gen}/google/protobuf/struct_pb.d.ts +28 -57
- package/dist/cjs/wkt/gen/google/protobuf/struct_pb.js +48 -0
- package/dist/{esm → cjs/wkt/gen}/google/protobuf/timestamp_pb.d.ts +6 -21
- package/dist/cjs/wkt/gen/google/protobuf/timestamp_pb.js +22 -0
- package/dist/{esm → cjs/wkt/gen}/google/protobuf/type_pb.d.ts +47 -82
- package/dist/cjs/wkt/gen/google/protobuf/type_pb.js +223 -0
- package/dist/cjs/wkt/gen/google/protobuf/wrappers_pb.d.ts +147 -0
- package/dist/cjs/wkt/gen/google/protobuf/wrappers_pb.js +46 -0
- package/dist/cjs/wkt/index.d.ts +15 -0
- package/dist/cjs/wkt/index.js +44 -0
- package/dist/cjs/wkt/timestamp.d.ts +21 -0
- package/dist/cjs/wkt/timestamp.js +58 -0
- package/dist/cjs/wkt/wrappers.d.ts +15 -0
- package/dist/cjs/wkt/wrappers.js +43 -0
- package/dist/esm/clone.d.ts +6 -0
- package/dist/esm/clone.js +73 -0
- package/dist/esm/codegenv1/boot.d.ts +63 -0
- package/dist/esm/codegenv1/boot.js +97 -0
- package/dist/esm/codegenv1/embed.d.ts +43 -0
- package/dist/esm/codegenv1/embed.js +232 -0
- package/dist/esm/codegenv1/enum.d.ts +17 -0
- package/dist/esm/codegenv1/enum.js +38 -0
- package/dist/esm/codegenv1/extension.d.ts +9 -0
- package/dist/esm/codegenv1/extension.js +25 -0
- package/dist/esm/codegenv1/file.d.ts +7 -0
- package/dist/esm/codegenv1/file.js +34 -0
- package/dist/esm/codegenv1/index.d.ts +9 -0
- package/dist/esm/codegenv1/index.js +22 -0
- package/dist/esm/codegenv1/message.d.ts +9 -0
- package/dist/esm/codegenv1/message.js +21 -0
- package/dist/esm/codegenv1/restore-json-names.d.ts +2 -0
- package/dist/esm/codegenv1/restore-json-names.js +23 -0
- package/dist/esm/codegenv1/service.d.ts +8 -0
- package/dist/esm/codegenv1/service.js +24 -0
- package/dist/esm/codegenv1/symbols.d.ts +116 -0
- package/dist/esm/codegenv1/symbols.js +55 -0
- package/dist/esm/codegenv1/types.d.ts +19 -0
- package/dist/esm/{field-list.js → codegenv1/types.js} +6 -0
- package/dist/esm/create.d.ts +9 -0
- package/dist/esm/create.js +239 -0
- package/dist/{cjs/descriptor-set.d.ts → esm/desc-types.d.ts} +144 -242
- package/dist/esm/equals.d.ts +9 -0
- package/dist/esm/equals.js +129 -0
- package/dist/esm/{extension-accessor.d.ts → extensions.d.ts} +11 -7
- package/dist/esm/extensions.js +130 -0
- package/dist/esm/fields.d.ts +22 -0
- package/dist/esm/fields.js +34 -0
- package/dist/esm/from-binary.d.ts +34 -0
- package/dist/esm/from-binary.js +215 -0
- package/dist/esm/from-json.d.ts +48 -0
- package/dist/esm/from-json.js +607 -0
- package/dist/esm/index.d.ts +16 -42
- package/dist/esm/index.js +13 -30
- package/dist/esm/is-message.d.ts +5 -20
- package/dist/esm/is-message.js +11 -29
- package/dist/esm/json-value.d.ts +16 -0
- package/dist/esm/proto-int64.js +2 -2
- package/dist/esm/reflect/error.d.ts +9 -0
- package/dist/esm/reflect/error.js +31 -0
- package/dist/esm/reflect/guard.d.ts +20 -0
- package/dist/esm/reflect/guard.js +70 -0
- package/dist/esm/reflect/index.d.ts +8 -0
- package/dist/esm/reflect/index.js +21 -0
- package/dist/esm/reflect/names.d.ts +23 -0
- package/dist/esm/reflect/names.js +106 -0
- package/dist/esm/reflect/nested-types.d.ts +2 -0
- package/dist/esm/reflect/nested-types.js +34 -0
- package/dist/esm/reflect/reflect-check.d.ts +10 -0
- package/dist/esm/reflect/reflect-check.js +143 -0
- package/dist/esm/reflect/reflect-types.d.ts +136 -0
- package/dist/esm/reflect/reflect-types.js +15 -0
- package/dist/esm/reflect/reflect.d.ts +23 -0
- package/dist/esm/reflect/reflect.js +403 -0
- package/dist/esm/reflect/registry.d.ts +82 -0
- package/dist/esm/reflect/registry.js +865 -0
- package/dist/{cjs → esm/reflect}/scalar.d.ts +21 -1
- package/dist/esm/reflect/scalar.js +289 -0
- package/dist/esm/reflect/unsafe.d.ts +58 -0
- package/dist/esm/reflect/unsafe.js +160 -0
- package/dist/esm/to-binary.d.ts +24 -0
- package/dist/esm/to-binary.js +189 -0
- package/dist/esm/to-json.d.ts +50 -0
- package/dist/esm/to-json.js +379 -0
- package/dist/esm/types.d.ts +68 -0
- package/dist/esm/wire/base64-encoding.d.ts +23 -0
- package/dist/esm/wire/base64-encoding.js +151 -0
- package/dist/esm/wire/binary-encoding.d.ts +242 -0
- package/dist/esm/{binary-encoding.js → wire/binary-encoding.js} +11 -10
- package/dist/esm/wire/index.d.ts +5 -0
- package/dist/esm/wire/index.js +18 -0
- package/dist/esm/wire/size-delimited.d.ts +51 -0
- package/dist/esm/wire/size-delimited.js +148 -0
- package/dist/esm/wire/text-encoding.d.ts +26 -0
- package/dist/esm/wire/text-encoding.js +50 -0
- package/dist/esm/wire/text-format.d.ts +14 -0
- package/dist/esm/{private → wire}/text-format.js +12 -2
- package/dist/{cjs/google → esm/wire}/varint.d.ts +2 -2
- package/dist/esm/{google → wire}/varint.js +11 -10
- package/dist/esm/wkt/any.d.ts +38 -0
- package/dist/esm/wkt/any.js +69 -0
- package/dist/esm/{google → wkt/gen/google}/protobuf/any_pb.d.ts +6 -27
- package/dist/esm/wkt/gen/google/protobuf/any_pb.js +19 -0
- package/dist/esm/{google → wkt/gen/google}/protobuf/api_pb.d.ts +14 -38
- package/dist/esm/wkt/gen/google/protobuf/api_pb.js +27 -0
- package/dist/esm/{google → wkt/gen/google}/protobuf/compiler/plugin_pb.d.ts +47 -77
- package/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.js +52 -0
- package/dist/esm/{google → wkt/gen/google}/protobuf/descriptor_pb.d.ts +384 -533
- package/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js +687 -0
- package/dist/{cjs → esm/wkt/gen}/google/protobuf/duration_pb.d.ts +6 -18
- package/dist/esm/wkt/gen/google/protobuf/duration_pb.js +19 -0
- package/dist/esm/wkt/gen/google/protobuf/empty_pb.d.ts +17 -0
- package/dist/esm/wkt/gen/google/protobuf/empty_pb.js +19 -0
- package/dist/{cjs → esm/wkt/gen}/google/protobuf/field_mask_pb.d.ts +6 -18
- package/dist/esm/wkt/gen/google/protobuf/field_mask_pb.js +19 -0
- package/dist/esm/wkt/gen/google/protobuf/source_context_pb.d.ts +19 -0
- package/dist/esm/wkt/gen/google/protobuf/source_context_pb.js +19 -0
- package/dist/{cjs → esm/wkt/gen}/google/protobuf/struct_pb.d.ts +28 -57
- package/dist/esm/wkt/gen/google/protobuf/struct_pb.js +45 -0
- package/dist/{cjs → esm/wkt/gen}/google/protobuf/timestamp_pb.d.ts +6 -21
- package/dist/esm/wkt/gen/google/protobuf/timestamp_pb.js +19 -0
- package/dist/{cjs → esm/wkt/gen}/google/protobuf/type_pb.d.ts +47 -82
- package/dist/esm/wkt/gen/google/protobuf/type_pb.js +220 -0
- package/dist/esm/wkt/gen/google/protobuf/wrappers_pb.d.ts +147 -0
- package/dist/esm/wkt/gen/google/protobuf/wrappers_pb.js +43 -0
- package/dist/esm/wkt/index.d.ts +15 -0
- package/dist/esm/wkt/index.js +28 -0
- package/dist/esm/wkt/timestamp.d.ts +21 -0
- package/dist/esm/wkt/timestamp.js +50 -0
- package/dist/esm/wkt/wrappers.d.ts +15 -0
- package/dist/esm/wkt/wrappers.js +38 -0
- package/package.json +39 -7
- package/dist/cjs/binary-encoding.d.ts +0 -420
- package/dist/cjs/binary-format.d.ts +0 -113
- package/dist/cjs/codegen-info.d.ts +0 -33
- package/dist/cjs/codegen-info.js +0 -69
- package/dist/cjs/create-descriptor-set.d.ts +0 -36
- package/dist/cjs/create-descriptor-set.js +0 -910
- package/dist/cjs/create-registry-from-desc.d.ts +0 -15
- package/dist/cjs/create-registry-from-desc.js +0 -264
- package/dist/cjs/create-registry.d.ts +0 -9
- package/dist/cjs/create-registry.js +0 -94
- package/dist/cjs/enum.d.ts +0 -35
- package/dist/cjs/extension-accessor.js +0 -114
- package/dist/cjs/extension.d.ts +0 -24
- package/dist/cjs/field-list.d.ts +0 -27
- package/dist/cjs/field-list.js +0 -15
- package/dist/cjs/field.d.ts +0 -314
- package/dist/cjs/field.js +0 -15
- package/dist/cjs/google/protobuf/any_pb.js +0 -273
- package/dist/cjs/google/protobuf/api_pb.js +0 -316
- package/dist/cjs/google/protobuf/compiler/plugin_pb.js +0 -219
- package/dist/cjs/google/protobuf/descriptor_pb.js +0 -2034
- package/dist/cjs/google/protobuf/duration_pb.js +0 -169
- package/dist/cjs/google/protobuf/empty_pb.d.ts +0 -28
- package/dist/cjs/google/protobuf/empty_pb.js +0 -52
- package/dist/cjs/google/protobuf/field_mask_pb.js +0 -311
- package/dist/cjs/google/protobuf/source_context_pb.d.ts +0 -29
- package/dist/cjs/google/protobuf/source_context_pb.js +0 -55
- package/dist/cjs/google/protobuf/struct_pb.js +0 -240
- package/dist/cjs/google/protobuf/timestamp_pb.js +0 -213
- package/dist/cjs/google/protobuf/type_pb.js +0 -562
- package/dist/cjs/google/protobuf/wrappers_pb.d.ts +0 -267
- package/dist/cjs/google/protobuf/wrappers_pb.js +0 -569
- package/dist/cjs/json-format.d.ts +0 -111
- package/dist/cjs/json-format.js +0 -15
- package/dist/cjs/message-type.d.ts +0 -51
- package/dist/cjs/message-type.js +0 -15
- package/dist/cjs/message.d.ts +0 -130
- package/dist/cjs/message.js +0 -128
- package/dist/cjs/private/binary-format.d.ts +0 -7
- package/dist/cjs/private/binary-format.js +0 -430
- package/dist/cjs/private/enum.d.ts +0 -27
- package/dist/cjs/private/enum.js +0 -94
- package/dist/cjs/private/extensions.d.ts +0 -34
- package/dist/cjs/private/extensions.js +0 -86
- package/dist/cjs/private/feature-set.d.ts +0 -19
- package/dist/cjs/private/feature-set.js +0 -106
- package/dist/cjs/private/field-list.d.ts +0 -18
- package/dist/cjs/private/field-list.js +0 -76
- package/dist/cjs/private/field-normalize.d.ts +0 -9
- package/dist/cjs/private/field-normalize.js +0 -69
- package/dist/cjs/private/field-wrapper.d.ts +0 -25
- package/dist/cjs/private/field-wrapper.js +0 -57
- package/dist/cjs/private/field.d.ts +0 -16
- package/dist/cjs/private/field.js +0 -45
- package/dist/cjs/private/json-format.d.ts +0 -2
- package/dist/cjs/private/json-format.js +0 -626
- package/dist/cjs/private/message-type.d.ts +0 -18
- package/dist/cjs/private/message-type.js +0 -50
- package/dist/cjs/private/names.d.ts +0 -43
- package/dist/cjs/private/names.js +0 -278
- package/dist/cjs/private/options-map.d.ts +0 -7
- package/dist/cjs/private/options-map.js +0 -15
- package/dist/cjs/private/proto-runtime.d.ts +0 -53
- package/dist/cjs/private/proto-runtime.js +0 -41
- package/dist/cjs/private/reflect.d.ts +0 -9
- package/dist/cjs/private/reflect.js +0 -79
- package/dist/cjs/private/reify-wkt.d.ts +0 -102
- package/dist/cjs/private/reify-wkt.js +0 -172
- package/dist/cjs/private/scalars.d.ts +0 -18
- package/dist/cjs/private/scalars.js +0 -105
- package/dist/cjs/private/text-format.d.ts +0 -4
- package/dist/cjs/private/util-common.d.ts +0 -2
- package/dist/cjs/private/util-common.js +0 -234
- package/dist/cjs/private/util.d.ts +0 -38
- package/dist/cjs/private/util.js +0 -15
- package/dist/cjs/proto-base64.d.ts +0 -18
- package/dist/cjs/proto-base64.js +0 -128
- package/dist/cjs/proto-delimited.d.ts +0 -54
- package/dist/cjs/proto-delimited.js +0 -155
- package/dist/cjs/proto-double.d.ts +0 -5
- package/dist/cjs/proto2.d.ts +0 -4
- package/dist/cjs/proto2.js +0 -53
- package/dist/cjs/proto3.d.ts +0 -4
- package/dist/cjs/proto3.js +0 -56
- package/dist/cjs/scalar.js +0 -81
- package/dist/cjs/service-type.d.ts +0 -96
- package/dist/cjs/service-type.js +0 -53
- package/dist/cjs/to-plain-message.d.ts +0 -12
- package/dist/cjs/to-plain-message.js +0 -72
- package/dist/cjs/type-registry.d.ts +0 -57
- package/dist/cjs/type-registry.js +0 -15
- package/dist/esm/binary-encoding.d.ts +0 -420
- package/dist/esm/binary-format.d.ts +0 -113
- package/dist/esm/codegen-info.d.ts +0 -33
- package/dist/esm/codegen-info.js +0 -67
- package/dist/esm/create-descriptor-set.d.ts +0 -36
- package/dist/esm/create-descriptor-set.js +0 -906
- package/dist/esm/create-registry-from-desc.d.ts +0 -15
- package/dist/esm/create-registry-from-desc.js +0 -261
- package/dist/esm/create-registry.d.ts +0 -9
- package/dist/esm/create-registry.js +0 -90
- package/dist/esm/descriptor-set.js +0 -14
- package/dist/esm/enum.d.ts +0 -35
- package/dist/esm/extension-accessor.js +0 -107
- package/dist/esm/extension.d.ts +0 -24
- package/dist/esm/field-list.d.ts +0 -27
- package/dist/esm/field.d.ts +0 -314
- package/dist/esm/field.js +0 -14
- package/dist/esm/google/protobuf/any_pb.js +0 -269
- package/dist/esm/google/protobuf/api_pb.js +0 -310
- package/dist/esm/google/protobuf/compiler/plugin_pb.js +0 -212
- package/dist/esm/google/protobuf/descriptor_pb.js +0 -1999
- package/dist/esm/google/protobuf/duration_pb.js +0 -165
- package/dist/esm/google/protobuf/empty_pb.d.ts +0 -28
- package/dist/esm/google/protobuf/empty_pb.js +0 -48
- package/dist/esm/google/protobuf/field_mask_pb.js +0 -307
- package/dist/esm/google/protobuf/source_context_pb.d.ts +0 -29
- package/dist/esm/google/protobuf/source_context_pb.js +0 -51
- package/dist/esm/google/protobuf/struct_pb.js +0 -234
- package/dist/esm/google/protobuf/timestamp_pb.js +0 -209
- package/dist/esm/google/protobuf/type_pb.js +0 -554
- package/dist/esm/google/protobuf/wrappers_pb.d.ts +0 -267
- package/dist/esm/google/protobuf/wrappers_pb.js +0 -557
- package/dist/esm/json-format.d.ts +0 -111
- package/dist/esm/json-format.js +0 -14
- package/dist/esm/message-type.d.ts +0 -51
- package/dist/esm/message-type.js +0 -14
- package/dist/esm/message.d.ts +0 -130
- package/dist/esm/message.js +0 -124
- package/dist/esm/private/binary-format.d.ts +0 -7
- package/dist/esm/private/binary-format.js +0 -426
- package/dist/esm/private/enum.d.ts +0 -27
- package/dist/esm/private/enum.js +0 -87
- package/dist/esm/private/extensions.d.ts +0 -34
- package/dist/esm/private/extensions.js +0 -81
- package/dist/esm/private/feature-set.d.ts +0 -19
- package/dist/esm/private/feature-set.js +0 -102
- package/dist/esm/private/field-list.d.ts +0 -18
- package/dist/esm/private/field-list.js +0 -72
- package/dist/esm/private/field-normalize.d.ts +0 -9
- package/dist/esm/private/field-normalize.js +0 -65
- package/dist/esm/private/field-wrapper.d.ts +0 -25
- package/dist/esm/private/field-wrapper.js +0 -53
- package/dist/esm/private/field.d.ts +0 -16
- package/dist/esm/private/field.js +0 -41
- package/dist/esm/private/json-format.d.ts +0 -2
- package/dist/esm/private/json-format.js +0 -623
- package/dist/esm/private/message-type.d.ts +0 -18
- package/dist/esm/private/message-type.js +0 -46
- package/dist/esm/private/names.d.ts +0 -43
- package/dist/esm/private/names.js +0 -269
- package/dist/esm/private/options-map.d.ts +0 -7
- package/dist/esm/private/options-map.js +0 -14
- package/dist/esm/private/proto-runtime.d.ts +0 -53
- package/dist/esm/private/proto-runtime.js +0 -37
- package/dist/esm/private/reflect.d.ts +0 -9
- package/dist/esm/private/reflect.js +0 -74
- package/dist/esm/private/reify-wkt.d.ts +0 -102
- package/dist/esm/private/reify-wkt.js +0 -168
- package/dist/esm/private/scalars.d.ts +0 -18
- package/dist/esm/private/scalars.js +0 -99
- package/dist/esm/private/text-format.d.ts +0 -4
- package/dist/esm/private/util-common.d.ts +0 -2
- package/dist/esm/private/util-common.js +0 -231
- package/dist/esm/private/util.d.ts +0 -38
- package/dist/esm/private/util.js +0 -14
- package/dist/esm/proto-base64.d.ts +0 -18
- package/dist/esm/proto-base64.js +0 -125
- package/dist/esm/proto-delimited.d.ts +0 -54
- package/dist/esm/proto-delimited.js +0 -152
- package/dist/esm/proto-double.d.ts +0 -5
- package/dist/esm/proto-double.js +0 -26
- package/dist/esm/proto2.d.ts +0 -4
- package/dist/esm/proto2.js +0 -50
- package/dist/esm/proto3.d.ts +0 -4
- package/dist/esm/proto3.js +0 -53
- package/dist/esm/scalar.js +0 -78
- package/dist/esm/service-type.d.ts +0 -96
- package/dist/esm/service-type.js +0 -50
- package/dist/esm/to-plain-message.d.ts +0 -12
- package/dist/esm/to-plain-message.js +0 -70
- package/dist/esm/type-registry.d.ts +0 -57
- package/dist/esm/type-registry.js +0 -14
- /package/dist/cjs/{binary-format.js → desc-types.js} +0 -0
- /package/dist/cjs/{descriptor-set.js → json-value.js} +0 -0
- /package/dist/cjs/{private → reflect}/assert.d.ts +0 -0
- /package/dist/cjs/{private → reflect}/assert.js +0 -0
- /package/dist/cjs/{enum.js → types.js} +0 -0
- /package/dist/esm/{binary-format.js → desc-types.js} +0 -0
- /package/dist/esm/{enum.js → json-value.js} +0 -0
- /package/dist/esm/{private → reflect}/assert.d.ts +0 -0
- /package/dist/esm/{private → reflect}/assert.js +0 -0
- /package/dist/esm/{extension.js → types.js} +0 -0
|
@@ -1,906 +0,0 @@
|
|
|
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 { Edition, FeatureSet_RepeatedFieldEncoding, FeatureSetDefaults, FieldDescriptorProto_Label, FieldDescriptorProto_Type, FieldOptions_JSType, FileDescriptorProto, FileDescriptorSet, MethodDescriptorProto, MethodOptions_IdempotencyLevel, ServiceDescriptorProto, SourceCodeInfo, } from "./google/protobuf/descriptor_pb.js";
|
|
15
|
-
import { assert } from "./private/assert.js";
|
|
16
|
-
import { MethodIdempotency, MethodKind } from "./service-type.js";
|
|
17
|
-
import { fieldJsonName, findEnumSharedPrefix } from "./private/names.js";
|
|
18
|
-
import { parseTextFormatEnumValue, parseTextFormatScalarValue, } from "./private/text-format.js";
|
|
19
|
-
import { createFeatureResolver } from "./private/feature-set.js";
|
|
20
|
-
import { LongType, ScalarType } from "./scalar.js";
|
|
21
|
-
import { isMessage } from "./is-message.js";
|
|
22
|
-
/**
|
|
23
|
-
* Create a DescriptorSet, a convenient interface for working with a set of
|
|
24
|
-
* google.protobuf.FileDescriptorProto.
|
|
25
|
-
*
|
|
26
|
-
* Note that files must be given in topological order, so each file appears
|
|
27
|
-
* before any file that imports it. Protocol buffer compilers always produce
|
|
28
|
-
* files in topological order.
|
|
29
|
-
*/
|
|
30
|
-
export function createDescriptorSet(input, options) {
|
|
31
|
-
var _a;
|
|
32
|
-
const cart = {
|
|
33
|
-
files: [],
|
|
34
|
-
enums: new Map(),
|
|
35
|
-
messages: new Map(),
|
|
36
|
-
services: new Map(),
|
|
37
|
-
extensions: new Map(),
|
|
38
|
-
mapEntries: new Map(),
|
|
39
|
-
};
|
|
40
|
-
const fileDescriptors = isMessage(input, FileDescriptorSet)
|
|
41
|
-
? input.file
|
|
42
|
-
: input instanceof Uint8Array
|
|
43
|
-
? FileDescriptorSet.fromBinary(input).file
|
|
44
|
-
: input;
|
|
45
|
-
const resolverByEdition = new Map();
|
|
46
|
-
for (const proto of fileDescriptors) {
|
|
47
|
-
const edition = (_a = proto.edition) !== null && _a !== void 0 ? _a : parseFileSyntax(proto.syntax, proto.edition).edition;
|
|
48
|
-
let resolveFeatures = resolverByEdition.get(edition);
|
|
49
|
-
if (resolveFeatures === undefined) {
|
|
50
|
-
resolveFeatures = createFeatureResolver(edition, options === null || options === void 0 ? void 0 : options.featureSetDefaults, options === null || options === void 0 ? void 0 : options.serializationOptions);
|
|
51
|
-
resolverByEdition.set(edition, resolveFeatures);
|
|
52
|
-
}
|
|
53
|
-
addFile(proto, cart, resolveFeatures);
|
|
54
|
-
}
|
|
55
|
-
return cart;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Create a descriptor for a file.
|
|
59
|
-
*/
|
|
60
|
-
function addFile(proto, cart, resolveFeatures) {
|
|
61
|
-
var _a, _b;
|
|
62
|
-
assert(proto.name, `invalid FileDescriptorProto: missing name`);
|
|
63
|
-
const file = Object.assign(Object.assign({ kind: "file", proto, deprecated: (_b = (_a = proto.options) === null || _a === void 0 ? void 0 : _a.deprecated) !== null && _b !== void 0 ? _b : false }, parseFileSyntax(proto.syntax, proto.edition)), { name: proto.name.replace(/\.proto/, ""), dependencies: findFileDependencies(proto, cart), enums: [], messages: [], extensions: [], services: [], toString() {
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- we asserted above
|
|
65
|
-
return `file ${this.proto.name}`;
|
|
66
|
-
},
|
|
67
|
-
getSyntaxComments() {
|
|
68
|
-
return findComments(this.proto.sourceCodeInfo, [
|
|
69
|
-
FieldNumber.FileDescriptorProto_Syntax,
|
|
70
|
-
]);
|
|
71
|
-
},
|
|
72
|
-
getPackageComments() {
|
|
73
|
-
return findComments(this.proto.sourceCodeInfo, [
|
|
74
|
-
FieldNumber.FileDescriptorProto_Package,
|
|
75
|
-
]);
|
|
76
|
-
},
|
|
77
|
-
getFeatures() {
|
|
78
|
-
var _a;
|
|
79
|
-
return resolveFeatures((_a = proto.options) === null || _a === void 0 ? void 0 : _a.features);
|
|
80
|
-
} });
|
|
81
|
-
cart.mapEntries.clear(); // map entries are local to the file, we can safely discard
|
|
82
|
-
for (const enumProto of proto.enumType) {
|
|
83
|
-
addEnum(enumProto, file, undefined, cart, resolveFeatures);
|
|
84
|
-
}
|
|
85
|
-
for (const messageProto of proto.messageType) {
|
|
86
|
-
addMessage(messageProto, file, undefined, cart, resolveFeatures);
|
|
87
|
-
}
|
|
88
|
-
for (const serviceProto of proto.service) {
|
|
89
|
-
addService(serviceProto, file, cart, resolveFeatures);
|
|
90
|
-
}
|
|
91
|
-
addExtensions(file, cart, resolveFeatures);
|
|
92
|
-
for (const mapEntry of cart.mapEntries.values()) {
|
|
93
|
-
addFields(mapEntry, cart, resolveFeatures);
|
|
94
|
-
}
|
|
95
|
-
for (const message of file.messages) {
|
|
96
|
-
addFields(message, cart, resolveFeatures);
|
|
97
|
-
addExtensions(message, cart, resolveFeatures);
|
|
98
|
-
}
|
|
99
|
-
cart.mapEntries.clear(); // map entries are local to the file, we can safely discard
|
|
100
|
-
cart.files.push(file);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Create descriptors for extensions, and add them to the message / file,
|
|
104
|
-
* and to our cart.
|
|
105
|
-
* Recurses into nested types.
|
|
106
|
-
*/
|
|
107
|
-
function addExtensions(desc, cart, resolveFeatures) {
|
|
108
|
-
switch (desc.kind) {
|
|
109
|
-
case "file":
|
|
110
|
-
for (const proto of desc.proto.extension) {
|
|
111
|
-
const ext = newExtension(proto, desc, undefined, cart, resolveFeatures);
|
|
112
|
-
desc.extensions.push(ext);
|
|
113
|
-
cart.extensions.set(ext.typeName, ext);
|
|
114
|
-
}
|
|
115
|
-
break;
|
|
116
|
-
case "message":
|
|
117
|
-
for (const proto of desc.proto.extension) {
|
|
118
|
-
const ext = newExtension(proto, desc.file, desc, cart, resolveFeatures);
|
|
119
|
-
desc.nestedExtensions.push(ext);
|
|
120
|
-
cart.extensions.set(ext.typeName, ext);
|
|
121
|
-
}
|
|
122
|
-
for (const message of desc.nestedMessages) {
|
|
123
|
-
addExtensions(message, cart, resolveFeatures);
|
|
124
|
-
}
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Create descriptors for fields and oneof groups, and add them to the message.
|
|
130
|
-
* Recurses into nested types.
|
|
131
|
-
*/
|
|
132
|
-
function addFields(message, cart, resolveFeatures) {
|
|
133
|
-
const allOneofs = message.proto.oneofDecl.map((proto) => newOneof(proto, message, resolveFeatures));
|
|
134
|
-
const oneofsSeen = new Set();
|
|
135
|
-
for (const proto of message.proto.field) {
|
|
136
|
-
const oneof = findOneof(proto, allOneofs);
|
|
137
|
-
const field = newField(proto, message.file, message, oneof, cart, resolveFeatures);
|
|
138
|
-
message.fields.push(field);
|
|
139
|
-
if (oneof === undefined) {
|
|
140
|
-
message.members.push(field);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
oneof.fields.push(field);
|
|
144
|
-
if (!oneofsSeen.has(oneof)) {
|
|
145
|
-
oneofsSeen.add(oneof);
|
|
146
|
-
message.members.push(oneof);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
for (const oneof of allOneofs.filter((o) => oneofsSeen.has(o))) {
|
|
151
|
-
message.oneofs.push(oneof);
|
|
152
|
-
}
|
|
153
|
-
for (const child of message.nestedMessages) {
|
|
154
|
-
addFields(child, cart, resolveFeatures);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Create a descriptor for an enumeration, and add it our cart and to the
|
|
159
|
-
* parent type, if any.
|
|
160
|
-
*/
|
|
161
|
-
function addEnum(proto, file, parent, cart, resolveFeatures) {
|
|
162
|
-
var _a, _b, _c;
|
|
163
|
-
assert(proto.name, `invalid EnumDescriptorProto: missing name`);
|
|
164
|
-
const desc = {
|
|
165
|
-
kind: "enum",
|
|
166
|
-
proto,
|
|
167
|
-
deprecated: (_b = (_a = proto.options) === null || _a === void 0 ? void 0 : _a.deprecated) !== null && _b !== void 0 ? _b : false,
|
|
168
|
-
file,
|
|
169
|
-
parent,
|
|
170
|
-
name: proto.name,
|
|
171
|
-
typeName: makeTypeName(proto, parent, file),
|
|
172
|
-
values: [],
|
|
173
|
-
sharedPrefix: findEnumSharedPrefix(proto.name, proto.value.map((v) => { var _a; return (_a = v.name) !== null && _a !== void 0 ? _a : ""; })),
|
|
174
|
-
toString() {
|
|
175
|
-
return `enum ${this.typeName}`;
|
|
176
|
-
},
|
|
177
|
-
getComments() {
|
|
178
|
-
const path = this.parent
|
|
179
|
-
? [
|
|
180
|
-
...this.parent.getComments().sourcePath,
|
|
181
|
-
FieldNumber.DescriptorProto_EnumType,
|
|
182
|
-
this.parent.proto.enumType.indexOf(this.proto),
|
|
183
|
-
]
|
|
184
|
-
: [
|
|
185
|
-
FieldNumber.FileDescriptorProto_EnumType,
|
|
186
|
-
this.file.proto.enumType.indexOf(this.proto),
|
|
187
|
-
];
|
|
188
|
-
return findComments(file.proto.sourceCodeInfo, path);
|
|
189
|
-
},
|
|
190
|
-
getFeatures() {
|
|
191
|
-
var _a, _b;
|
|
192
|
-
return resolveFeatures((_a = parent === null || parent === void 0 ? void 0 : parent.getFeatures()) !== null && _a !== void 0 ? _a : file.getFeatures(), (_b = proto.options) === null || _b === void 0 ? void 0 : _b.features);
|
|
193
|
-
},
|
|
194
|
-
};
|
|
195
|
-
cart.enums.set(desc.typeName, desc);
|
|
196
|
-
proto.value.forEach((proto) => {
|
|
197
|
-
var _a, _b;
|
|
198
|
-
assert(proto.name, `invalid EnumValueDescriptorProto: missing name`);
|
|
199
|
-
assert(proto.number !== undefined, `invalid EnumValueDescriptorProto: missing number`);
|
|
200
|
-
desc.values.push({
|
|
201
|
-
kind: "enum_value",
|
|
202
|
-
proto,
|
|
203
|
-
deprecated: (_b = (_a = proto.options) === null || _a === void 0 ? void 0 : _a.deprecated) !== null && _b !== void 0 ? _b : false,
|
|
204
|
-
parent: desc,
|
|
205
|
-
name: proto.name,
|
|
206
|
-
number: proto.number,
|
|
207
|
-
toString() {
|
|
208
|
-
return `enum value ${desc.typeName}.${this.name}`;
|
|
209
|
-
},
|
|
210
|
-
declarationString() {
|
|
211
|
-
var _a;
|
|
212
|
-
let str = `${this.name} = ${this.number}`;
|
|
213
|
-
if (((_a = this.proto.options) === null || _a === void 0 ? void 0 : _a.deprecated) === true) {
|
|
214
|
-
str += " [deprecated = true]";
|
|
215
|
-
}
|
|
216
|
-
return str;
|
|
217
|
-
},
|
|
218
|
-
getComments() {
|
|
219
|
-
const path = [
|
|
220
|
-
...this.parent.getComments().sourcePath,
|
|
221
|
-
FieldNumber.EnumDescriptorProto_Value,
|
|
222
|
-
this.parent.proto.value.indexOf(this.proto),
|
|
223
|
-
];
|
|
224
|
-
return findComments(file.proto.sourceCodeInfo, path);
|
|
225
|
-
},
|
|
226
|
-
getFeatures() {
|
|
227
|
-
var _a;
|
|
228
|
-
return resolveFeatures(desc.getFeatures(), (_a = proto.options) === null || _a === void 0 ? void 0 : _a.features);
|
|
229
|
-
},
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
((_c = parent === null || parent === void 0 ? void 0 : parent.nestedEnums) !== null && _c !== void 0 ? _c : file.enums).push(desc);
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Create a descriptor for a message, including nested types, and add it to our
|
|
236
|
-
* cart. Note that this does not create descriptors fields.
|
|
237
|
-
*/
|
|
238
|
-
function addMessage(proto, file, parent, cart, resolveFeatures) {
|
|
239
|
-
var _a, _b, _c, _d;
|
|
240
|
-
assert(proto.name, `invalid DescriptorProto: missing name`);
|
|
241
|
-
const desc = {
|
|
242
|
-
kind: "message",
|
|
243
|
-
proto,
|
|
244
|
-
deprecated: (_b = (_a = proto.options) === null || _a === void 0 ? void 0 : _a.deprecated) !== null && _b !== void 0 ? _b : false,
|
|
245
|
-
file,
|
|
246
|
-
parent,
|
|
247
|
-
name: proto.name,
|
|
248
|
-
typeName: makeTypeName(proto, parent, file),
|
|
249
|
-
fields: [],
|
|
250
|
-
oneofs: [],
|
|
251
|
-
members: [],
|
|
252
|
-
nestedEnums: [],
|
|
253
|
-
nestedMessages: [],
|
|
254
|
-
nestedExtensions: [],
|
|
255
|
-
toString() {
|
|
256
|
-
return `message ${this.typeName}`;
|
|
257
|
-
},
|
|
258
|
-
getComments() {
|
|
259
|
-
const path = this.parent
|
|
260
|
-
? [
|
|
261
|
-
...this.parent.getComments().sourcePath,
|
|
262
|
-
FieldNumber.DescriptorProto_NestedType,
|
|
263
|
-
this.parent.proto.nestedType.indexOf(this.proto),
|
|
264
|
-
]
|
|
265
|
-
: [
|
|
266
|
-
FieldNumber.FileDescriptorProto_MessageType,
|
|
267
|
-
this.file.proto.messageType.indexOf(this.proto),
|
|
268
|
-
];
|
|
269
|
-
return findComments(file.proto.sourceCodeInfo, path);
|
|
270
|
-
},
|
|
271
|
-
getFeatures() {
|
|
272
|
-
var _a, _b;
|
|
273
|
-
return resolveFeatures((_a = parent === null || parent === void 0 ? void 0 : parent.getFeatures()) !== null && _a !== void 0 ? _a : file.getFeatures(), (_b = proto.options) === null || _b === void 0 ? void 0 : _b.features);
|
|
274
|
-
},
|
|
275
|
-
};
|
|
276
|
-
if (((_c = proto.options) === null || _c === void 0 ? void 0 : _c.mapEntry) === true) {
|
|
277
|
-
cart.mapEntries.set(desc.typeName, desc);
|
|
278
|
-
}
|
|
279
|
-
else {
|
|
280
|
-
((_d = parent === null || parent === void 0 ? void 0 : parent.nestedMessages) !== null && _d !== void 0 ? _d : file.messages).push(desc);
|
|
281
|
-
cart.messages.set(desc.typeName, desc);
|
|
282
|
-
}
|
|
283
|
-
for (const enumProto of proto.enumType) {
|
|
284
|
-
addEnum(enumProto, file, desc, cart, resolveFeatures);
|
|
285
|
-
}
|
|
286
|
-
for (const messageProto of proto.nestedType) {
|
|
287
|
-
addMessage(messageProto, file, desc, cart, resolveFeatures);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Create a descriptor for a service, including methods, and add it to our
|
|
292
|
-
* cart.
|
|
293
|
-
*/
|
|
294
|
-
function addService(proto, file, cart, resolveFeatures) {
|
|
295
|
-
var _a, _b;
|
|
296
|
-
assert(proto.name, `invalid ServiceDescriptorProto: missing name`);
|
|
297
|
-
const desc = {
|
|
298
|
-
kind: "service",
|
|
299
|
-
proto,
|
|
300
|
-
deprecated: (_b = (_a = proto.options) === null || _a === void 0 ? void 0 : _a.deprecated) !== null && _b !== void 0 ? _b : false,
|
|
301
|
-
file,
|
|
302
|
-
name: proto.name,
|
|
303
|
-
typeName: makeTypeName(proto, undefined, file),
|
|
304
|
-
methods: [],
|
|
305
|
-
toString() {
|
|
306
|
-
return `service ${this.typeName}`;
|
|
307
|
-
},
|
|
308
|
-
getComments() {
|
|
309
|
-
const path = [
|
|
310
|
-
FieldNumber.FileDescriptorProto_Service,
|
|
311
|
-
this.file.proto.service.indexOf(this.proto),
|
|
312
|
-
];
|
|
313
|
-
return findComments(file.proto.sourceCodeInfo, path);
|
|
314
|
-
},
|
|
315
|
-
getFeatures() {
|
|
316
|
-
var _a;
|
|
317
|
-
return resolveFeatures(file.getFeatures(), (_a = proto.options) === null || _a === void 0 ? void 0 : _a.features);
|
|
318
|
-
},
|
|
319
|
-
};
|
|
320
|
-
file.services.push(desc);
|
|
321
|
-
cart.services.set(desc.typeName, desc);
|
|
322
|
-
for (const methodProto of proto.method) {
|
|
323
|
-
desc.methods.push(newMethod(methodProto, desc, cart, resolveFeatures));
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Create a descriptor for a method.
|
|
328
|
-
*/
|
|
329
|
-
function newMethod(proto, parent, cart, resolveFeatures) {
|
|
330
|
-
var _a, _b, _c;
|
|
331
|
-
assert(proto.name, `invalid MethodDescriptorProto: missing name`);
|
|
332
|
-
assert(proto.inputType, `invalid MethodDescriptorProto: missing input_type`);
|
|
333
|
-
assert(proto.outputType, `invalid MethodDescriptorProto: missing output_type`);
|
|
334
|
-
let methodKind;
|
|
335
|
-
if (proto.clientStreaming === true && proto.serverStreaming === true) {
|
|
336
|
-
methodKind = MethodKind.BiDiStreaming;
|
|
337
|
-
}
|
|
338
|
-
else if (proto.clientStreaming === true) {
|
|
339
|
-
methodKind = MethodKind.ClientStreaming;
|
|
340
|
-
}
|
|
341
|
-
else if (proto.serverStreaming === true) {
|
|
342
|
-
methodKind = MethodKind.ServerStreaming;
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
methodKind = MethodKind.Unary;
|
|
346
|
-
}
|
|
347
|
-
let idempotency;
|
|
348
|
-
switch ((_a = proto.options) === null || _a === void 0 ? void 0 : _a.idempotencyLevel) {
|
|
349
|
-
case MethodOptions_IdempotencyLevel.IDEMPOTENT:
|
|
350
|
-
idempotency = MethodIdempotency.Idempotent;
|
|
351
|
-
break;
|
|
352
|
-
case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS:
|
|
353
|
-
idempotency = MethodIdempotency.NoSideEffects;
|
|
354
|
-
break;
|
|
355
|
-
case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN:
|
|
356
|
-
case undefined:
|
|
357
|
-
idempotency = undefined;
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
const input = cart.messages.get(trimLeadingDot(proto.inputType));
|
|
361
|
-
const output = cart.messages.get(trimLeadingDot(proto.outputType));
|
|
362
|
-
assert(input, `invalid MethodDescriptorProto: input_type ${proto.inputType} not found`);
|
|
363
|
-
assert(output, `invalid MethodDescriptorProto: output_type ${proto.inputType} not found`);
|
|
364
|
-
const name = proto.name;
|
|
365
|
-
return {
|
|
366
|
-
kind: "rpc",
|
|
367
|
-
proto,
|
|
368
|
-
deprecated: (_c = (_b = proto.options) === null || _b === void 0 ? void 0 : _b.deprecated) !== null && _c !== void 0 ? _c : false,
|
|
369
|
-
parent,
|
|
370
|
-
name,
|
|
371
|
-
methodKind,
|
|
372
|
-
input,
|
|
373
|
-
output,
|
|
374
|
-
idempotency,
|
|
375
|
-
toString() {
|
|
376
|
-
return `rpc ${parent.typeName}.${name}`;
|
|
377
|
-
},
|
|
378
|
-
getComments() {
|
|
379
|
-
const path = [
|
|
380
|
-
...this.parent.getComments().sourcePath,
|
|
381
|
-
FieldNumber.ServiceDescriptorProto_Method,
|
|
382
|
-
this.parent.proto.method.indexOf(this.proto),
|
|
383
|
-
];
|
|
384
|
-
return findComments(parent.file.proto.sourceCodeInfo, path);
|
|
385
|
-
},
|
|
386
|
-
getFeatures() {
|
|
387
|
-
var _a;
|
|
388
|
-
return resolveFeatures(parent.getFeatures(), (_a = proto.options) === null || _a === void 0 ? void 0 : _a.features);
|
|
389
|
-
},
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Create a descriptor for a oneof group.
|
|
394
|
-
*/
|
|
395
|
-
function newOneof(proto, parent, resolveFeatures) {
|
|
396
|
-
assert(proto.name, `invalid OneofDescriptorProto: missing name`);
|
|
397
|
-
return {
|
|
398
|
-
kind: "oneof",
|
|
399
|
-
proto,
|
|
400
|
-
deprecated: false,
|
|
401
|
-
parent,
|
|
402
|
-
fields: [],
|
|
403
|
-
name: proto.name,
|
|
404
|
-
toString() {
|
|
405
|
-
return `oneof ${parent.typeName}.${this.name}`;
|
|
406
|
-
},
|
|
407
|
-
getComments() {
|
|
408
|
-
const path = [
|
|
409
|
-
...this.parent.getComments().sourcePath,
|
|
410
|
-
FieldNumber.DescriptorProto_OneofDecl,
|
|
411
|
-
this.parent.proto.oneofDecl.indexOf(this.proto),
|
|
412
|
-
];
|
|
413
|
-
return findComments(parent.file.proto.sourceCodeInfo, path);
|
|
414
|
-
},
|
|
415
|
-
getFeatures() {
|
|
416
|
-
var _a;
|
|
417
|
-
return resolveFeatures(parent.getFeatures(), (_a = proto.options) === null || _a === void 0 ? void 0 : _a.features);
|
|
418
|
-
},
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Create a descriptor for a field.
|
|
423
|
-
*/
|
|
424
|
-
function newField(proto, file, parent, oneof, cart, resolveFeatures) {
|
|
425
|
-
var _a, _b, _c;
|
|
426
|
-
assert(proto.name, `invalid FieldDescriptorProto: missing name`);
|
|
427
|
-
assert(proto.number, `invalid FieldDescriptorProto: missing number`);
|
|
428
|
-
assert(proto.type, `invalid FieldDescriptorProto: missing type`);
|
|
429
|
-
const common = {
|
|
430
|
-
proto,
|
|
431
|
-
deprecated: (_b = (_a = proto.options) === null || _a === void 0 ? void 0 : _a.deprecated) !== null && _b !== void 0 ? _b : false,
|
|
432
|
-
name: proto.name,
|
|
433
|
-
number: proto.number,
|
|
434
|
-
parent,
|
|
435
|
-
oneof,
|
|
436
|
-
optional: isOptionalField(proto, file.syntax),
|
|
437
|
-
packedByDefault: isPackedFieldByDefault(proto, resolveFeatures),
|
|
438
|
-
packed: isPackedField(file, parent, proto, resolveFeatures),
|
|
439
|
-
jsonName: proto.jsonName === fieldJsonName(proto.name) ? undefined : proto.jsonName,
|
|
440
|
-
scalar: undefined,
|
|
441
|
-
longType: undefined,
|
|
442
|
-
message: undefined,
|
|
443
|
-
enum: undefined,
|
|
444
|
-
mapKey: undefined,
|
|
445
|
-
mapValue: undefined,
|
|
446
|
-
declarationString,
|
|
447
|
-
// toString, getComments, getFeatures are overridden in newExtension
|
|
448
|
-
toString() {
|
|
449
|
-
return `field ${this.parent.typeName}.${this.name}`;
|
|
450
|
-
},
|
|
451
|
-
getComments() {
|
|
452
|
-
const path = [
|
|
453
|
-
...this.parent.getComments().sourcePath,
|
|
454
|
-
FieldNumber.DescriptorProto_Field,
|
|
455
|
-
this.parent.proto.field.indexOf(this.proto),
|
|
456
|
-
];
|
|
457
|
-
return findComments(file.proto.sourceCodeInfo, path);
|
|
458
|
-
},
|
|
459
|
-
getFeatures() {
|
|
460
|
-
var _a;
|
|
461
|
-
return resolveFeatures(parent.getFeatures(), (_a = proto.options) === null || _a === void 0 ? void 0 : _a.features);
|
|
462
|
-
},
|
|
463
|
-
};
|
|
464
|
-
const repeated = proto.label === FieldDescriptorProto_Label.REPEATED;
|
|
465
|
-
switch (proto.type) {
|
|
466
|
-
case FieldDescriptorProto_Type.MESSAGE:
|
|
467
|
-
case FieldDescriptorProto_Type.GROUP: {
|
|
468
|
-
assert(proto.typeName, `invalid FieldDescriptorProto: missing type_name`);
|
|
469
|
-
const mapEntry = cart.mapEntries.get(trimLeadingDot(proto.typeName));
|
|
470
|
-
if (mapEntry !== undefined) {
|
|
471
|
-
assert(repeated, `invalid FieldDescriptorProto: expected map entry to be repeated`);
|
|
472
|
-
return Object.assign(Object.assign(Object.assign({}, common), { kind: "field", fieldKind: "map", repeated: false }), getMapFieldTypes(mapEntry));
|
|
473
|
-
}
|
|
474
|
-
const message = cart.messages.get(trimLeadingDot(proto.typeName));
|
|
475
|
-
assert(message !== undefined, `invalid FieldDescriptorProto: type_name ${proto.typeName} not found`);
|
|
476
|
-
return Object.assign(Object.assign({}, common), { kind: "field", fieldKind: "message", repeated,
|
|
477
|
-
message });
|
|
478
|
-
}
|
|
479
|
-
case FieldDescriptorProto_Type.ENUM: {
|
|
480
|
-
assert(proto.typeName, `invalid FieldDescriptorProto: missing type_name`);
|
|
481
|
-
const e = cart.enums.get(trimLeadingDot(proto.typeName));
|
|
482
|
-
assert(e !== undefined, `invalid FieldDescriptorProto: type_name ${proto.typeName} not found`);
|
|
483
|
-
return Object.assign(Object.assign({}, common), { kind: "field", fieldKind: "enum", getDefaultValue,
|
|
484
|
-
repeated, enum: e });
|
|
485
|
-
}
|
|
486
|
-
default: {
|
|
487
|
-
const scalar = fieldTypeToScalarType[proto.type];
|
|
488
|
-
assert(scalar, `invalid FieldDescriptorProto: unknown type ${proto.type}`);
|
|
489
|
-
return Object.assign(Object.assign({}, common), { kind: "field", fieldKind: "scalar", getDefaultValue,
|
|
490
|
-
repeated,
|
|
491
|
-
scalar, longType: ((_c = proto.options) === null || _c === void 0 ? void 0 : _c.jstype) == FieldOptions_JSType.JS_STRING
|
|
492
|
-
? LongType.STRING
|
|
493
|
-
: LongType.BIGINT });
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* Create a descriptor for an extension field.
|
|
499
|
-
*/
|
|
500
|
-
function newExtension(proto, file, parent, cart, resolveFeatures) {
|
|
501
|
-
assert(proto.extendee, `invalid FieldDescriptorProto: missing extendee`);
|
|
502
|
-
const field = newField(proto, file, null, // to safe us many lines of duplicated code, we trick the type system
|
|
503
|
-
undefined, cart, resolveFeatures);
|
|
504
|
-
const extendee = cart.messages.get(trimLeadingDot(proto.extendee));
|
|
505
|
-
assert(extendee, `invalid FieldDescriptorProto: extendee ${proto.extendee} not found`);
|
|
506
|
-
return Object.assign(Object.assign({}, field), { kind: "extension", typeName: makeTypeName(proto, parent, file), parent,
|
|
507
|
-
file,
|
|
508
|
-
extendee,
|
|
509
|
-
// Must override toString, getComments, getFeatures from newField, because we
|
|
510
|
-
// call newField with parent undefined.
|
|
511
|
-
toString() {
|
|
512
|
-
return `extension ${this.typeName}`;
|
|
513
|
-
},
|
|
514
|
-
getComments() {
|
|
515
|
-
const path = this.parent
|
|
516
|
-
? [
|
|
517
|
-
...this.parent.getComments().sourcePath,
|
|
518
|
-
FieldNumber.DescriptorProto_Extension,
|
|
519
|
-
this.parent.proto.extension.indexOf(proto),
|
|
520
|
-
]
|
|
521
|
-
: [
|
|
522
|
-
FieldNumber.FileDescriptorProto_Extension,
|
|
523
|
-
this.file.proto.extension.indexOf(proto),
|
|
524
|
-
];
|
|
525
|
-
return findComments(file.proto.sourceCodeInfo, path);
|
|
526
|
-
},
|
|
527
|
-
getFeatures() {
|
|
528
|
-
var _a;
|
|
529
|
-
return resolveFeatures((parent !== null && parent !== void 0 ? parent : file).getFeatures(), (_a = proto.options) === null || _a === void 0 ? void 0 : _a.features);
|
|
530
|
-
} });
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Parse the "syntax" and "edition" fields, stripping test editions.
|
|
534
|
-
*/
|
|
535
|
-
function parseFileSyntax(syntax, edition) {
|
|
536
|
-
let e;
|
|
537
|
-
let s;
|
|
538
|
-
switch (syntax) {
|
|
539
|
-
case undefined:
|
|
540
|
-
case "proto2":
|
|
541
|
-
s = "proto2";
|
|
542
|
-
e = Edition.EDITION_PROTO2;
|
|
543
|
-
break;
|
|
544
|
-
case "proto3":
|
|
545
|
-
s = "proto3";
|
|
546
|
-
e = Edition.EDITION_PROTO3;
|
|
547
|
-
break;
|
|
548
|
-
case "editions":
|
|
549
|
-
s = "editions";
|
|
550
|
-
switch (edition) {
|
|
551
|
-
case undefined:
|
|
552
|
-
case Edition.EDITION_1_TEST_ONLY:
|
|
553
|
-
case Edition.EDITION_2_TEST_ONLY:
|
|
554
|
-
case Edition.EDITION_99997_TEST_ONLY:
|
|
555
|
-
case Edition.EDITION_99998_TEST_ONLY:
|
|
556
|
-
case Edition.EDITION_99999_TEST_ONLY:
|
|
557
|
-
case Edition.EDITION_UNKNOWN:
|
|
558
|
-
e = Edition.EDITION_UNKNOWN;
|
|
559
|
-
break;
|
|
560
|
-
default:
|
|
561
|
-
e = edition;
|
|
562
|
-
break;
|
|
563
|
-
}
|
|
564
|
-
break;
|
|
565
|
-
default:
|
|
566
|
-
throw new Error(`invalid FileDescriptorProto: unsupported syntax: ${syntax}`);
|
|
567
|
-
}
|
|
568
|
-
if (syntax === "editions" && edition === Edition.EDITION_UNKNOWN) {
|
|
569
|
-
throw new Error(`invalid FileDescriptorProto: syntax ${syntax} cannot have edition ${String(edition)}`);
|
|
570
|
-
}
|
|
571
|
-
return {
|
|
572
|
-
syntax: s,
|
|
573
|
-
edition: e,
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
/**
|
|
577
|
-
* Resolve dependencies of FileDescriptorProto to DescFile.
|
|
578
|
-
*/
|
|
579
|
-
function findFileDependencies(proto, cart) {
|
|
580
|
-
return proto.dependency.map((wantName) => {
|
|
581
|
-
const dep = cart.files.find((f) => f.proto.name === wantName);
|
|
582
|
-
assert(dep);
|
|
583
|
-
return dep;
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* Create a fully qualified name for a protobuf type or extension field.
|
|
588
|
-
*
|
|
589
|
-
* The fully qualified name for messages, enumerations, and services is
|
|
590
|
-
* constructed by concatenating the package name (if present), parent
|
|
591
|
-
* message names (for nested types), and the type name. We omit the leading
|
|
592
|
-
* dot added by protobuf compilers. Examples:
|
|
593
|
-
* - mypackage.MyMessage
|
|
594
|
-
* - mypackage.MyMessage.NestedMessage
|
|
595
|
-
*
|
|
596
|
-
* The fully qualified name for extension fields is constructed by
|
|
597
|
-
* concatenating the package name (if present), parent message names (for
|
|
598
|
-
* extensions declared within a message), and the field name. Examples:
|
|
599
|
-
* - mypackage.extfield
|
|
600
|
-
* - mypackage.MyMessage.extfield
|
|
601
|
-
*/
|
|
602
|
-
function makeTypeName(proto, parent, file) {
|
|
603
|
-
assert(proto.name, `invalid ${proto.getType().typeName}: missing name`);
|
|
604
|
-
let typeName;
|
|
605
|
-
if (parent) {
|
|
606
|
-
typeName = `${parent.typeName}.${proto.name}`;
|
|
607
|
-
}
|
|
608
|
-
else if (file.proto.package !== undefined) {
|
|
609
|
-
typeName = `${file.proto.package}.${proto.name}`;
|
|
610
|
-
}
|
|
611
|
-
else {
|
|
612
|
-
typeName = `${proto.name}`;
|
|
613
|
-
}
|
|
614
|
-
return typeName;
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* Remove the leading dot from a fully qualified type name.
|
|
618
|
-
*/
|
|
619
|
-
function trimLeadingDot(typeName) {
|
|
620
|
-
return typeName.startsWith(".") ? typeName.substring(1) : typeName;
|
|
621
|
-
}
|
|
622
|
-
function getMapFieldTypes(mapEntry) {
|
|
623
|
-
var _a, _b;
|
|
624
|
-
assert((_a = mapEntry.proto.options) === null || _a === void 0 ? void 0 : _a.mapEntry, `invalid DescriptorProto: expected ${mapEntry.toString()} to be a map entry`);
|
|
625
|
-
assert(mapEntry.fields.length === 2, `invalid DescriptorProto: map entry ${mapEntry.toString()} has ${mapEntry.fields.length} fields`);
|
|
626
|
-
const keyField = mapEntry.fields.find((f) => f.proto.number === 1);
|
|
627
|
-
assert(keyField, `invalid DescriptorProto: map entry ${mapEntry.toString()} is missing key field`);
|
|
628
|
-
const mapKey = keyField.scalar;
|
|
629
|
-
assert(mapKey !== undefined &&
|
|
630
|
-
mapKey !== ScalarType.BYTES &&
|
|
631
|
-
mapKey !== ScalarType.FLOAT &&
|
|
632
|
-
mapKey !== ScalarType.DOUBLE, `invalid DescriptorProto: map entry ${mapEntry.toString()} has unexpected key type ${(_b = keyField.proto.type) !== null && _b !== void 0 ? _b : -1}`);
|
|
633
|
-
const valueField = mapEntry.fields.find((f) => f.proto.number === 2);
|
|
634
|
-
assert(valueField, `invalid DescriptorProto: map entry ${mapEntry.toString()} is missing value field`);
|
|
635
|
-
switch (valueField.fieldKind) {
|
|
636
|
-
case "scalar":
|
|
637
|
-
return {
|
|
638
|
-
mapKey,
|
|
639
|
-
mapValue: Object.assign(Object.assign({}, valueField), { kind: "scalar" }),
|
|
640
|
-
};
|
|
641
|
-
case "message":
|
|
642
|
-
return {
|
|
643
|
-
mapKey,
|
|
644
|
-
mapValue: Object.assign(Object.assign({}, valueField), { kind: "message" }),
|
|
645
|
-
};
|
|
646
|
-
case "enum":
|
|
647
|
-
return {
|
|
648
|
-
mapKey,
|
|
649
|
-
mapValue: Object.assign(Object.assign({}, valueField), { kind: "enum" }),
|
|
650
|
-
};
|
|
651
|
-
default:
|
|
652
|
-
throw new Error("invalid DescriptorProto: unsupported map entry value field");
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Did the user put the field in a oneof group?
|
|
657
|
-
* This handles proto3 optionals.
|
|
658
|
-
*/
|
|
659
|
-
function findOneof(proto, allOneofs) {
|
|
660
|
-
var _a;
|
|
661
|
-
const oneofIndex = proto.oneofIndex;
|
|
662
|
-
if (oneofIndex === undefined) {
|
|
663
|
-
return undefined;
|
|
664
|
-
}
|
|
665
|
-
let oneof;
|
|
666
|
-
if (proto.proto3Optional !== true) {
|
|
667
|
-
oneof = allOneofs[oneofIndex];
|
|
668
|
-
assert(oneof, `invalid FieldDescriptorProto: oneof #${oneofIndex} for field #${(_a = proto.number) !== null && _a !== void 0 ? _a : -1} not found`);
|
|
669
|
-
}
|
|
670
|
-
return oneof;
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* Did the user use the `optional` keyword?
|
|
674
|
-
* This handles proto3 optionals.
|
|
675
|
-
*/
|
|
676
|
-
function isOptionalField(proto, syntax) {
|
|
677
|
-
switch (syntax) {
|
|
678
|
-
case "proto2":
|
|
679
|
-
return (proto.oneofIndex === undefined &&
|
|
680
|
-
proto.label === FieldDescriptorProto_Label.OPTIONAL);
|
|
681
|
-
case "proto3":
|
|
682
|
-
return proto.proto3Optional === true;
|
|
683
|
-
case "editions":
|
|
684
|
-
return false;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
/**
|
|
688
|
-
* Is this field packed by default? Only valid for repeated enum fields, and
|
|
689
|
-
* for repeated scalar fields except BYTES and STRING.
|
|
690
|
-
*
|
|
691
|
-
* In proto3 syntax, fields are packed by default. In proto2 syntax, fields
|
|
692
|
-
* are unpacked by default. With editions, the default is whatever the edition
|
|
693
|
-
* specifies as a default. In edition 2023, fields are packed by default.
|
|
694
|
-
*/
|
|
695
|
-
function isPackedFieldByDefault(proto, resolveFeatures) {
|
|
696
|
-
const { repeatedFieldEncoding } = resolveFeatures();
|
|
697
|
-
if (repeatedFieldEncoding != FeatureSet_RepeatedFieldEncoding.PACKED) {
|
|
698
|
-
return false;
|
|
699
|
-
}
|
|
700
|
-
// From the proto3 language guide:
|
|
701
|
-
// > In proto3, repeated fields of scalar numeric types are packed by default.
|
|
702
|
-
// This information is incomplete - according to the conformance tests, BOOL
|
|
703
|
-
// and ENUM are packed by default as well. This means only STRING and BYTES
|
|
704
|
-
// are not packed by default, which makes sense because they are length-delimited.
|
|
705
|
-
switch (proto.type) {
|
|
706
|
-
case FieldDescriptorProto_Type.STRING:
|
|
707
|
-
case FieldDescriptorProto_Type.BYTES:
|
|
708
|
-
case FieldDescriptorProto_Type.GROUP:
|
|
709
|
-
case FieldDescriptorProto_Type.MESSAGE:
|
|
710
|
-
return false;
|
|
711
|
-
default:
|
|
712
|
-
return true;
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
/**
|
|
716
|
-
* Pack this repeated field?
|
|
717
|
-
*
|
|
718
|
-
* Respects field type, proto2/proto3 defaults and the `packed` option, or
|
|
719
|
-
* edition defaults and the edition features.repeated_field_encoding options.
|
|
720
|
-
*/
|
|
721
|
-
function isPackedField(file, parent, proto, resolveFeatures) {
|
|
722
|
-
var _a, _b, _c, _d, _e, _f;
|
|
723
|
-
switch (proto.type) {
|
|
724
|
-
case FieldDescriptorProto_Type.STRING:
|
|
725
|
-
case FieldDescriptorProto_Type.BYTES:
|
|
726
|
-
case FieldDescriptorProto_Type.GROUP:
|
|
727
|
-
case FieldDescriptorProto_Type.MESSAGE:
|
|
728
|
-
// length-delimited types cannot be packed
|
|
729
|
-
return false;
|
|
730
|
-
default:
|
|
731
|
-
switch (file.edition) {
|
|
732
|
-
case Edition.EDITION_PROTO2:
|
|
733
|
-
return (_b = (_a = proto.options) === null || _a === void 0 ? void 0 : _a.packed) !== null && _b !== void 0 ? _b : false;
|
|
734
|
-
case Edition.EDITION_PROTO3:
|
|
735
|
-
return (_d = (_c = proto.options) === null || _c === void 0 ? void 0 : _c.packed) !== null && _d !== void 0 ? _d : true;
|
|
736
|
-
default: {
|
|
737
|
-
const { repeatedFieldEncoding } = resolveFeatures((_e = parent === null || parent === void 0 ? void 0 : parent.getFeatures()) !== null && _e !== void 0 ? _e : file.getFeatures(), (_f = proto.options) === null || _f === void 0 ? void 0 : _f.features);
|
|
738
|
-
return (repeatedFieldEncoding == FeatureSet_RepeatedFieldEncoding.PACKED);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
/**
|
|
744
|
-
* Map from a compiler-generated field type to our ScalarType, which is a
|
|
745
|
-
* subset of field types declared by protobuf enum google.protobuf.FieldDescriptorProto.
|
|
746
|
-
*/
|
|
747
|
-
const fieldTypeToScalarType = {
|
|
748
|
-
[FieldDescriptorProto_Type.DOUBLE]: ScalarType.DOUBLE,
|
|
749
|
-
[FieldDescriptorProto_Type.FLOAT]: ScalarType.FLOAT,
|
|
750
|
-
[FieldDescriptorProto_Type.INT64]: ScalarType.INT64,
|
|
751
|
-
[FieldDescriptorProto_Type.UINT64]: ScalarType.UINT64,
|
|
752
|
-
[FieldDescriptorProto_Type.INT32]: ScalarType.INT32,
|
|
753
|
-
[FieldDescriptorProto_Type.FIXED64]: ScalarType.FIXED64,
|
|
754
|
-
[FieldDescriptorProto_Type.FIXED32]: ScalarType.FIXED32,
|
|
755
|
-
[FieldDescriptorProto_Type.BOOL]: ScalarType.BOOL,
|
|
756
|
-
[FieldDescriptorProto_Type.STRING]: ScalarType.STRING,
|
|
757
|
-
[FieldDescriptorProto_Type.GROUP]: undefined,
|
|
758
|
-
[FieldDescriptorProto_Type.MESSAGE]: undefined,
|
|
759
|
-
[FieldDescriptorProto_Type.BYTES]: ScalarType.BYTES,
|
|
760
|
-
[FieldDescriptorProto_Type.UINT32]: ScalarType.UINT32,
|
|
761
|
-
[FieldDescriptorProto_Type.ENUM]: undefined,
|
|
762
|
-
[FieldDescriptorProto_Type.SFIXED32]: ScalarType.SFIXED32,
|
|
763
|
-
[FieldDescriptorProto_Type.SFIXED64]: ScalarType.SFIXED64,
|
|
764
|
-
[FieldDescriptorProto_Type.SINT32]: ScalarType.SINT32,
|
|
765
|
-
[FieldDescriptorProto_Type.SINT64]: ScalarType.SINT64,
|
|
766
|
-
};
|
|
767
|
-
/**
|
|
768
|
-
* Find comments.
|
|
769
|
-
*/
|
|
770
|
-
function findComments(sourceCodeInfo, sourcePath) {
|
|
771
|
-
if (!sourceCodeInfo) {
|
|
772
|
-
return {
|
|
773
|
-
leadingDetached: [],
|
|
774
|
-
sourcePath,
|
|
775
|
-
};
|
|
776
|
-
}
|
|
777
|
-
for (const location of sourceCodeInfo.location) {
|
|
778
|
-
if (location.path.length !== sourcePath.length) {
|
|
779
|
-
continue;
|
|
780
|
-
}
|
|
781
|
-
if (location.path.some((value, index) => sourcePath[index] !== value)) {
|
|
782
|
-
continue;
|
|
783
|
-
}
|
|
784
|
-
return {
|
|
785
|
-
leadingDetached: location.leadingDetachedComments,
|
|
786
|
-
leading: location.leadingComments,
|
|
787
|
-
trailing: location.trailingComments,
|
|
788
|
-
sourcePath,
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
return {
|
|
792
|
-
leadingDetached: [],
|
|
793
|
-
sourcePath,
|
|
794
|
-
};
|
|
795
|
-
}
|
|
796
|
-
/**
|
|
797
|
-
* The following field numbers are used to find comments in
|
|
798
|
-
* google.protobuf.SourceCodeInfo.
|
|
799
|
-
*/
|
|
800
|
-
var FieldNumber;
|
|
801
|
-
(function (FieldNumber) {
|
|
802
|
-
FieldNumber[FieldNumber["FileDescriptorProto_Package"] = 2] = "FileDescriptorProto_Package";
|
|
803
|
-
FieldNumber[FieldNumber["FileDescriptorProto_MessageType"] = 4] = "FileDescriptorProto_MessageType";
|
|
804
|
-
FieldNumber[FieldNumber["FileDescriptorProto_EnumType"] = 5] = "FileDescriptorProto_EnumType";
|
|
805
|
-
FieldNumber[FieldNumber["FileDescriptorProto_Service"] = 6] = "FileDescriptorProto_Service";
|
|
806
|
-
FieldNumber[FieldNumber["FileDescriptorProto_Extension"] = 7] = "FileDescriptorProto_Extension";
|
|
807
|
-
FieldNumber[FieldNumber["FileDescriptorProto_Syntax"] = 12] = "FileDescriptorProto_Syntax";
|
|
808
|
-
FieldNumber[FieldNumber["DescriptorProto_Field"] = 2] = "DescriptorProto_Field";
|
|
809
|
-
FieldNumber[FieldNumber["DescriptorProto_NestedType"] = 3] = "DescriptorProto_NestedType";
|
|
810
|
-
FieldNumber[FieldNumber["DescriptorProto_EnumType"] = 4] = "DescriptorProto_EnumType";
|
|
811
|
-
FieldNumber[FieldNumber["DescriptorProto_Extension"] = 6] = "DescriptorProto_Extension";
|
|
812
|
-
FieldNumber[FieldNumber["DescriptorProto_OneofDecl"] = 8] = "DescriptorProto_OneofDecl";
|
|
813
|
-
FieldNumber[FieldNumber["EnumDescriptorProto_Value"] = 2] = "EnumDescriptorProto_Value";
|
|
814
|
-
FieldNumber[FieldNumber["ServiceDescriptorProto_Method"] = 2] = "ServiceDescriptorProto_Method";
|
|
815
|
-
})(FieldNumber || (FieldNumber = {}));
|
|
816
|
-
/**
|
|
817
|
-
* Return a string that matches the definition of a field in the protobuf
|
|
818
|
-
* source. Does not take custom options into account.
|
|
819
|
-
*/
|
|
820
|
-
function declarationString() {
|
|
821
|
-
var _a, _b, _c;
|
|
822
|
-
const parts = [];
|
|
823
|
-
if (this.repeated) {
|
|
824
|
-
parts.push("repeated");
|
|
825
|
-
}
|
|
826
|
-
if (this.optional) {
|
|
827
|
-
parts.push("optional");
|
|
828
|
-
}
|
|
829
|
-
const file = this.kind === "extension" ? this.file : this.parent.file;
|
|
830
|
-
if (file.syntax == "proto2" &&
|
|
831
|
-
this.proto.label === FieldDescriptorProto_Label.REQUIRED) {
|
|
832
|
-
parts.push("required");
|
|
833
|
-
}
|
|
834
|
-
let type;
|
|
835
|
-
switch (this.fieldKind) {
|
|
836
|
-
case "scalar":
|
|
837
|
-
type = ScalarType[this.scalar].toLowerCase();
|
|
838
|
-
break;
|
|
839
|
-
case "enum":
|
|
840
|
-
type = this.enum.typeName;
|
|
841
|
-
break;
|
|
842
|
-
case "message":
|
|
843
|
-
type = this.message.typeName;
|
|
844
|
-
break;
|
|
845
|
-
case "map": {
|
|
846
|
-
const k = ScalarType[this.mapKey].toLowerCase();
|
|
847
|
-
let v;
|
|
848
|
-
switch (this.mapValue.kind) {
|
|
849
|
-
case "scalar":
|
|
850
|
-
v = ScalarType[this.mapValue.scalar].toLowerCase();
|
|
851
|
-
break;
|
|
852
|
-
case "enum":
|
|
853
|
-
v = this.mapValue.enum.typeName;
|
|
854
|
-
break;
|
|
855
|
-
case "message":
|
|
856
|
-
v = this.mapValue.message.typeName;
|
|
857
|
-
break;
|
|
858
|
-
}
|
|
859
|
-
type = `map<${k}, ${v}>`;
|
|
860
|
-
break;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
parts.push(`${type} ${this.name} = ${this.number}`);
|
|
864
|
-
const options = [];
|
|
865
|
-
if (((_a = this.proto.options) === null || _a === void 0 ? void 0 : _a.packed) !== undefined) {
|
|
866
|
-
options.push(`packed = ${this.proto.options.packed.toString()}`);
|
|
867
|
-
}
|
|
868
|
-
let defaultValue = this.proto.defaultValue;
|
|
869
|
-
if (defaultValue !== undefined) {
|
|
870
|
-
if (this.proto.type == FieldDescriptorProto_Type.BYTES ||
|
|
871
|
-
this.proto.type == FieldDescriptorProto_Type.STRING) {
|
|
872
|
-
defaultValue = '"' + defaultValue.replace('"', '\\"') + '"';
|
|
873
|
-
}
|
|
874
|
-
options.push(`default = ${defaultValue}`);
|
|
875
|
-
}
|
|
876
|
-
if (this.jsonName !== undefined) {
|
|
877
|
-
options.push(`json_name = "${this.jsonName}"`);
|
|
878
|
-
}
|
|
879
|
-
if (((_b = this.proto.options) === null || _b === void 0 ? void 0 : _b.jstype) !== undefined) {
|
|
880
|
-
options.push(`jstype = ${FieldOptions_JSType[this.proto.options.jstype]}`);
|
|
881
|
-
}
|
|
882
|
-
if (((_c = this.proto.options) === null || _c === void 0 ? void 0 : _c.deprecated) === true) {
|
|
883
|
-
options.push(`deprecated = true`);
|
|
884
|
-
}
|
|
885
|
-
if (options.length > 0) {
|
|
886
|
-
parts.push("[" + options.join(", ") + "]");
|
|
887
|
-
}
|
|
888
|
-
return parts.join(" ");
|
|
889
|
-
}
|
|
890
|
-
/**
|
|
891
|
-
* Parses a text-encoded default value (proto2) of a scalar or enum field.
|
|
892
|
-
*/
|
|
893
|
-
function getDefaultValue() {
|
|
894
|
-
const d = this.proto.defaultValue;
|
|
895
|
-
if (d === undefined) {
|
|
896
|
-
return undefined;
|
|
897
|
-
}
|
|
898
|
-
switch (this.fieldKind) {
|
|
899
|
-
case "enum":
|
|
900
|
-
return parseTextFormatEnumValue(this.enum, d);
|
|
901
|
-
case "scalar":
|
|
902
|
-
return parseTextFormatScalarValue(this.scalar, d);
|
|
903
|
-
default:
|
|
904
|
-
return undefined;
|
|
905
|
-
}
|
|
906
|
-
}
|