Skip to content
// EFFECT DAYS 2026

ProtobufDescriptor

Descriptors of .proto files: their messages, enums, extensions and services, resolved from the FileDescriptorProtos that protoc, buf, gRPC server reflection and protoc plugins exchange.

Mental model

  • A Registry holds the files of one set of .proto files and finds their types by full name, such as "acme.v1.User".
  • Descriptors are resolved: every field states its presence, packing, encoding and UTF-8 validation, as the file's syntax or edition and its features decide them, and refers to the descriptor of its type.
  • ProtobufMessage encodes and decodes the values of a message descriptor. Neither module depends on Effect Schema. A Schema can separately transform these plain values into application types.
  • Field and oneof names are preserved exactly in JavaScript values.

Gotchas

  • Type references must be fully qualified, with a leading dot, as protoc and buf write them.
  • proto2, proto3 and editions 2023, 2024 and 2026 are supported. Unknown editions are rejected rather than interpreted with older defaults.
  • Descriptors are compiler output. Source-level naming, visibility and definition-size rules are enforced by protoc, before runtime resolution.
  • descriptor.proto itself is part of this module: descriptorFile, and per message an interface and a MessageDescriptor of the same name, such as FileDescriptorProto, generated from protoc's descriptor of it.

Example Finding a message

import { Result } from "effect"
import { ProtobufDescriptor } from "effect/protobuf"
const registry = Result.getOrThrow(ProtobufDescriptor.make([{
name: "user.proto",
package: "acme.v1",
syntax: "proto3",
dependency: [],
message_type: [{
name: "User",
field: [{ name: "display_name", number: 1, label: 1, type: 9 }]
}]
}]))
const user = registry.getMessage("acme.v1.User")!
user.fields.map((field) => field.name) // => ["display_name"]
137 exports Since v4.1.5 Source

Constructors

Decodes a FileDescriptorSet, as protoc --descriptor_set_out and buf build write it, and resolves its files into a Registry.

Signature

declare function fromFileDescriptorSet(bytes: Uint8Array): Result<Registry, ProtobufDescriptorError>
Since v4.1.5

Resolves FileDescriptorProtos into a Registry. Files may come in any order, but every dependency must be among them.

Details

Resolving checks references and the field layout used by the message codec, including field-number bounds, duplicate names and numbers, oneof membership, and map key types. Invalid layouts return a ProtobufDescriptorError. This does not replace protoc's validation of .proto source files.

Signature

declare function make(files: Iterable<FileDescriptorProto>): Result<Registry, ProtobufDescriptorError>

Example Resolving a file

import { Result } from "effect"
import { ProtobufDescriptor } from "effect/protobuf"
const registry = Result.getOrThrow(ProtobufDescriptor.make([{
name: "point.proto",
syntax: "proto3",
dependency: [],
message_type: [{
name: "Point",
field: [
{ name: "x", number: 1, label: 1, type: 5 },
{ name: "y", number: 2, label: 1, type: 5 }
]
}]
}]))
const x = registry.getMessage("Point")!.fields[0]
x.kind === "singular" && x.presence // => "implicit"

Descriptor.Proto

The resolved google/protobuf/descriptor.proto.

Signature

declare const descriptorFile: ProtobufDescriptor.FileDescriptor

The descriptor of google.protobuf.DescriptorProto.

Signature

declare const DescriptorProto: MessageDescriptor
Since v4.1.5

Describes a message type.

Signature

interface DescriptorProto {
readonly enum_type?: readonly Array<EnumDescriptorProto>;
readonly extension?: readonly Array<FieldDescriptorProto>;
readonly extension_range?: readonly Array<DescriptorProto_ExtensionRange>;
readonly field?: readonly Array<FieldDescriptorProto>;
readonly name?: string;
readonly nested_type?: readonly Array<DescriptorProto>;
readonly oneof_decl?: readonly Array<OneofDescriptorProto>;
readonly options?: MessageOptions;
readonly reserved_name?: readonly Array<string>;
readonly reserved_range?: readonly Array<DescriptorProto_ReservedRange>;
readonly visibility?: SymbolVisibility;
}

The descriptor of google.protobuf.DescriptorProto.ExtensionRange.

Signature

declare const DescriptorProto_ExtensionRange: MessageDescriptor

The fields of google.protobuf.DescriptorProto.ExtensionRange.

Signature

interface DescriptorProto_ExtensionRange {
readonly end?: number;
readonly options?: ExtensionRangeOptions;
readonly start?: number;
}

The descriptor of google.protobuf.DescriptorProto.ReservedRange.

Signature

declare const DescriptorProto_ReservedRange: MessageDescriptor

Range of reserved tag numbers. Reserved tag numbers may not be used by fields or extension ranges in the same message. Reserved ranges may not overlap.

Signature

interface DescriptorProto_ReservedRange {
readonly end?: number;
readonly start?: number;
}
Since v4.1.5

The full set of known editions.

Signature

declare const Edition: {
readonly EDITION_1_TEST_ONLY: 1;
readonly EDITION_2_TEST_ONLY: 2;
readonly EDITION_2023: 1000;
readonly EDITION_2024: 1001;
readonly EDITION_2026: 1002;
readonly EDITION_99997_TEST_ONLY: 99997;
readonly EDITION_99998_TEST_ONLY: 99998;
readonly EDITION_99999_TEST_ONLY: 99999;
readonly EDITION_LEGACY: 900;
readonly EDITION_MAX: 2147483647;
readonly EDITION_PROTO2: 998;
readonly EDITION_PROTO3: 999;
readonly EDITION_UNKNOWN: 0;
readonly EDITION_UNSTABLE: 9999;
}
Since v4.1.5

A value of google.protobuf.Edition.

Signature

type Edition = typeof Edition[keyof typeof Edition]

The descriptor of google.protobuf.EnumDescriptorProto.

Signature

declare const EnumDescriptorProto: MessageDescriptor
Since v4.1.5

Describes an enum type.

Signature

interface EnumDescriptorProto {
readonly name?: string;
readonly options?: EnumOptions;
readonly reserved_name?: readonly Array<string>;
readonly reserved_range?: readonly Array<EnumDescriptorProto_EnumReservedRange>;
readonly value?: readonly Array<EnumValueDescriptorProto>;
readonly visibility?: SymbolVisibility;
}

The descriptor of google.protobuf.EnumDescriptorProto.EnumReservedRange.

Signature

declare const EnumDescriptorProto_EnumReservedRange: MessageDescriptor

Range of reserved numeric values. Reserved values may not be used by entries in the same enum. Reserved ranges may not overlap.

Details

Note that this is distinct from DescriptorProto.ReservedRange in that it is inclusive such that it can appropriately represent the entire int32 domain.

Signature

interface EnumDescriptorProto_EnumReservedRange {
readonly end?: number;
readonly start?: number;
}

The descriptor of google.protobuf.EnumOptions.

Signature

declare const EnumOptions: MessageDescriptor

EnumOptions

interface
Since v4.1.5

The fields of google.protobuf.EnumOptions.

Signature

interface EnumOptions {
readonly allow_alias?: boolean;
readonly deprecated?: boolean;
readonly deprecated_legacy_json_field_conflicts?: boolean;
readonly features?: FeatureSet;
readonly uninterpreted_option?: readonly Array<UninterpretedOption>;
}

The descriptor of google.protobuf.EnumValueDescriptorProto.

Signature

declare const EnumValueDescriptorProto: MessageDescriptor

Describes a value within an enum.

Signature

interface EnumValueDescriptorProto {
readonly name?: string;
readonly number?: number;
readonly options?: EnumValueOptions;
}

The descriptor of google.protobuf.EnumValueOptions.

Signature

declare const EnumValueOptions: MessageDescriptor
Since v4.1.5

The fields of google.protobuf.EnumValueOptions.

Signature

interface EnumValueOptions {
readonly debug_redact?: boolean;
readonly deprecated?: boolean;
readonly feature_support?: FieldOptions_FeatureSupport;
readonly features?: FeatureSet;
readonly uninterpreted_option?: readonly Array<UninterpretedOption>;
}

The descriptor of google.protobuf.ExtensionRangeOptions.

Signature

declare const ExtensionRangeOptions: MessageDescriptor
Since v4.1.5

The fields of google.protobuf.ExtensionRangeOptions.

Signature

interface ExtensionRangeOptions {
readonly declaration?: readonly Array<ExtensionRangeOptions_Declaration>;
readonly features?: FeatureSet;
readonly uninterpreted_option?: readonly Array<UninterpretedOption>;
readonly verification?: ExtensionRangeOptions_VerificationState;
}

The descriptor of google.protobuf.ExtensionRangeOptions.Declaration.

Signature

declare const ExtensionRangeOptions_Declaration: MessageDescriptor

The fields of google.protobuf.ExtensionRangeOptions.Declaration.

Signature

interface ExtensionRangeOptions_Declaration {
readonly full_name?: string;
readonly number?: number;
readonly repeated?: boolean;
readonly reserved?: boolean;
readonly type?: string;
}

The verification state of the extension range.

Signature

declare const ExtensionRangeOptions_VerificationState: {
readonly DECLARATION: 0;
readonly UNVERIFIED: 1;
}

A value of google.protobuf.ExtensionRangeOptions.VerificationState.

Signature

type ExtensionRangeOptions_VerificationState = typeof ExtensionRangeOptions_VerificationState[keyof typeof ExtensionRangeOptions_VerificationState]

The descriptor of google.protobuf.FeatureSet.

Signature

declare const FeatureSet: MessageDescriptor

FeatureSet

interface
Since v4.1.5

TODO Enums in C++ gencode (and potentially other languages) are not well scoped. This means that each of the feature enums below can clash with each other. The short names we've chosen maximize call-site readability, but leave us very open to this scenario. A future feature will be designed and implemented to handle this, hopefully before we ever hit a conflict here.

Signature

interface FeatureSet {
readonly default_symbol_visibility?: FeatureSet_VisibilityFeature_DefaultSymbolVisibility;
readonly enforce_naming_style?: FeatureSet_EnforceNamingStyle;
readonly enforce_proto_limits?: FeatureSet_ProtoLimitsFeature_EnforceProtoLimits;
readonly enum_type?: FeatureSet_EnumType;
readonly field_presence?: FeatureSet_FieldPresence;
readonly json_format?: FeatureSet_JsonFormat;
readonly message_encoding?: FeatureSet_MessageEncoding;
readonly repeated_field_encoding?: FeatureSet_RepeatedFieldEncoding;
readonly utf8_validation?: FeatureSet_Utf8Validation;
}

The values of google.protobuf.FeatureSet.EnforceNamingStyle.

Signature

declare const FeatureSet_EnforceNamingStyle: {
readonly ENFORCE_NAMING_STYLE_UNKNOWN: 0;
readonly STYLE_LEGACY: 2;
readonly STYLE2024: 1;
readonly STYLE2026: 3;
}

A value of google.protobuf.FeatureSet.EnforceNamingStyle.

Signature

type FeatureSet_EnforceNamingStyle = typeof FeatureSet_EnforceNamingStyle[keyof typeof FeatureSet_EnforceNamingStyle]

The values of google.protobuf.FeatureSet.EnumType.

Signature

declare const FeatureSet_EnumType: {
readonly CLOSED: 2;
readonly ENUM_TYPE_UNKNOWN: 0;
readonly OPEN: 1;
}

A value of google.protobuf.FeatureSet.EnumType.

Signature

type FeatureSet_EnumType = typeof FeatureSet_EnumType[keyof typeof FeatureSet_EnumType]

The values of google.protobuf.FeatureSet.FieldPresence.

Signature

declare const FeatureSet_FieldPresence: {
readonly EXPLICIT: 1;
readonly FIELD_PRESENCE_UNKNOWN: 0;
readonly IMPLICIT: 2;
readonly LEGACY_REQUIRED: 3;
}

A value of google.protobuf.FeatureSet.FieldPresence.

Signature

type FeatureSet_FieldPresence = typeof FeatureSet_FieldPresence[keyof typeof FeatureSet_FieldPresence]

The values of google.protobuf.FeatureSet.JsonFormat.

Signature

declare const FeatureSet_JsonFormat: {
readonly ALLOW: 1;
readonly JSON_FORMAT_UNKNOWN: 0;
readonly LEGACY_BEST_EFFORT: 2;
}

A value of google.protobuf.FeatureSet.JsonFormat.

Signature

type FeatureSet_JsonFormat = typeof FeatureSet_JsonFormat[keyof typeof FeatureSet_JsonFormat]

The values of google.protobuf.FeatureSet.MessageEncoding.

Signature

declare const FeatureSet_MessageEncoding: {
readonly DELIMITED: 2;
readonly LENGTH_PREFIXED: 1;
readonly MESSAGE_ENCODING_UNKNOWN: 0;
}

A value of google.protobuf.FeatureSet.MessageEncoding.

Signature

type FeatureSet_MessageEncoding = typeof FeatureSet_MessageEncoding[keyof typeof FeatureSet_MessageEncoding]

The descriptor of google.protobuf.FeatureSet.ProtoLimitsFeature.

Signature

declare const FeatureSet_ProtoLimitsFeature: MessageDescriptor

The fields of google.protobuf.FeatureSet.ProtoLimitsFeature.

Signature

interface FeatureSet_ProtoLimitsFeature {}

The values of google.protobuf.FeatureSet.ProtoLimitsFeature.EnforceProtoLimits.

Signature

declare const FeatureSet_ProtoLimitsFeature_EnforceProtoLimits: {
readonly LEGACY_NO_EXPLICIT_LIMITS: 1;
readonly PROTO_LIMITS_UNKNOWN: 0;
readonly PROTO_LIMITS2026: 2;
}

A value of google.protobuf.FeatureSet.ProtoLimitsFeature.EnforceProtoLimits.

Signature

type FeatureSet_ProtoLimitsFeature_EnforceProtoLimits = typeof FeatureSet_ProtoLimitsFeature_EnforceProtoLimits[keyof typeof FeatureSet_ProtoLimitsFeature_EnforceProtoLimits]

The values of google.protobuf.FeatureSet.RepeatedFieldEncoding.

Signature

declare const FeatureSet_RepeatedFieldEncoding: {
readonly EXPANDED: 2;
readonly PACKED: 1;
readonly REPEATED_FIELD_ENCODING_UNKNOWN: 0;
}

A value of google.protobuf.FeatureSet.RepeatedFieldEncoding.

Signature

type FeatureSet_RepeatedFieldEncoding = typeof FeatureSet_RepeatedFieldEncoding[keyof typeof FeatureSet_RepeatedFieldEncoding]

The values of google.protobuf.FeatureSet.Utf8Validation.

Signature

declare const FeatureSet_Utf8Validation: {
readonly NONE: 3;
readonly UTF8_VALIDATION_UNKNOWN: 0;
readonly VERIFY: 2;
}

A value of google.protobuf.FeatureSet.Utf8Validation.

Signature

type FeatureSet_Utf8Validation = typeof FeatureSet_Utf8Validation[keyof typeof FeatureSet_Utf8Validation]

The descriptor of google.protobuf.FeatureSet.VisibilityFeature.

Signature

declare const FeatureSet_VisibilityFeature: MessageDescriptor

The fields of google.protobuf.FeatureSet.VisibilityFeature.

Signature

interface FeatureSet_VisibilityFeature {}

The values of google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility.

Signature

declare const FeatureSet_VisibilityFeature_DefaultSymbolVisibility: {
readonly DEFAULT_SYMBOL_VISIBILITY_UNKNOWN: 0;
readonly EXPORT_ALL: 1;
readonly EXPORT_TOP_LEVEL: 2;
readonly LOCAL_ALL: 3;
readonly STRICT: 4;
}

A value of google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility.

Signature

type FeatureSet_VisibilityFeature_DefaultSymbolVisibility = typeof FeatureSet_VisibilityFeature_DefaultSymbolVisibility[keyof typeof FeatureSet_VisibilityFeature_DefaultSymbolVisibility]

The descriptor of google.protobuf.FeatureSetDefaults.

Signature

declare const FeatureSetDefaults: MessageDescriptor
Since v4.1.5

A compiled specification for the defaults of a set of features. These messages are generated from FeatureSet extensions and can be used to seed feature resolution. The resolution with this object becomes a simple search for the closest matching edition, followed by proto merges.

Signature

interface FeatureSetDefaults {
readonly defaults?: readonly Array<FeatureSetDefaults_FeatureSetEditionDefault>;
readonly maximum_edition?: Edition;
readonly minimum_edition?: Edition;
}

The descriptor of google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.

Signature

declare const FeatureSetDefaults_FeatureSetEditionDefault: MessageDescriptor

A map from every known edition with a unique set of defaults to its defaults. Not all editions may be contained here. For a given edition, the defaults at the closest matching edition ordered at or before it should be used. This field must be in strict ascending order by edition.

Signature

interface FeatureSetDefaults_FeatureSetEditionDefault {
readonly edition?: Edition;
readonly fixed_features?: FeatureSet;
readonly overridable_features?: FeatureSet;
}

The descriptor of google.protobuf.FieldDescriptorProto.

Signature

declare const FieldDescriptorProto: MessageDescriptor
Since v4.1.5

Describes a field within a message.

Signature

interface FieldDescriptorProto {
readonly default_value?: string;
readonly extendee?: string;
readonly json_name?: string;
readonly label?: FieldDescriptorProto_Label;
readonly name?: string;
readonly number?: number;
readonly oneof_index?: number;
readonly options?: FieldOptions;
readonly proto3_optional?: boolean;
readonly type?: FieldDescriptorProto_Type;
readonly type_name?: string;
}

The values of google.protobuf.FieldDescriptorProto.Label.

Signature

declare const FieldDescriptorProto_Label: {
readonly LABEL_OPTIONAL: 1;
readonly LABEL_REPEATED: 3;
readonly LABEL_REQUIRED: 2;
}

A value of google.protobuf.FieldDescriptorProto.Label.

Signature

type FieldDescriptorProto_Label = typeof FieldDescriptorProto_Label[keyof typeof FieldDescriptorProto_Label]

The values of google.protobuf.FieldDescriptorProto.Type.

Signature

declare const FieldDescriptorProto_Type: {
readonly TYPE_BOOL: 8;
readonly TYPE_BYTES: 12;
readonly TYPE_DOUBLE: 1;
readonly TYPE_ENUM: 14;
readonly TYPE_FIXED32: 7;
readonly TYPE_FIXED64: 6;
readonly TYPE_FLOAT: 2;
readonly TYPE_GROUP: 10;
readonly TYPE_INT32: 5;
readonly TYPE_INT64: 3;
readonly TYPE_MESSAGE: 11;
readonly TYPE_SFIXED32: 15;
readonly TYPE_SFIXED64: 16;
readonly TYPE_SINT32: 17;
readonly TYPE_SINT64: 18;
readonly TYPE_STRING: 9;
readonly TYPE_UINT32: 13;
readonly TYPE_UINT64: 4;
}

A value of google.protobuf.FieldDescriptorProto.Type.

Signature

type FieldDescriptorProto_Type = typeof FieldDescriptorProto_Type[keyof typeof FieldDescriptorProto_Type]

The descriptor of google.protobuf.FieldOptions.

Signature

declare const FieldOptions: MessageDescriptor

FieldOptions

interface
Since v4.1.5

The fields of google.protobuf.FieldOptions.

Signature

interface FieldOptions {
readonly ctype?: FieldOptions_CType;
readonly debug_redact?: boolean;
readonly deprecated?: boolean;
readonly edition_defaults?: readonly Array<FieldOptions_EditionDefault>;
readonly feature_support?: FieldOptions_FeatureSupport;
readonly features?: FeatureSet;
readonly jstype?: FieldOptions_JSType;
readonly lazy?: boolean;
readonly packed?: boolean;
readonly retention?: FieldOptions_OptionRetention;
readonly targets?: readonly Array<FieldOptions_OptionTargetType>;
readonly uninterpreted_option?: readonly Array<UninterpretedOption>;
readonly unverified_lazy?: boolean;
readonly weak?: boolean;
}

The values of google.protobuf.FieldOptions.CType.

Signature

declare const FieldOptions_CType: {
readonly CORD: 1;
readonly STRING: 0;
readonly STRING_PIECE: 2;
}

A value of google.protobuf.FieldOptions.CType.

Signature

type FieldOptions_CType = typeof FieldOptions_CType[keyof typeof FieldOptions_CType]

The descriptor of google.protobuf.FieldOptions.EditionDefault.

Signature

declare const FieldOptions_EditionDefault: MessageDescriptor

The fields of google.protobuf.FieldOptions.EditionDefault.

Signature

interface FieldOptions_EditionDefault {
readonly edition?: Edition;
readonly value?: string;
}

The descriptor of google.protobuf.FieldOptions.FeatureSupport.

Signature

declare const FieldOptions_FeatureSupport: MessageDescriptor

Information about the support window of a feature.

Signature

interface FieldOptions_FeatureSupport {
readonly deprecation_warning?: string;
readonly edition_deprecated?: Edition;
readonly edition_introduced?: Edition;
readonly edition_removed?: Edition;
readonly removal_error?: string;
}

The values of google.protobuf.FieldOptions.JSType.

Signature

declare const FieldOptions_JSType: {
readonly JS_NORMAL: 0;
readonly JS_NUMBER: 2;
readonly JS_STRING: 1;
}

A value of google.protobuf.FieldOptions.JSType.

Signature

type FieldOptions_JSType = typeof FieldOptions_JSType[keyof typeof FieldOptions_JSType]

If set to RETENTION_SOURCE, the option will be omitted from the binary.

Signature

declare const FieldOptions_OptionRetention: {
readonly RETENTION_RUNTIME: 1;
readonly RETENTION_SOURCE: 2;
readonly RETENTION_UNKNOWN: 0;
}

A value of google.protobuf.FieldOptions.OptionRetention.

Signature

type FieldOptions_OptionRetention = typeof FieldOptions_OptionRetention[keyof typeof FieldOptions_OptionRetention]

This indicates the types of entities that the field may apply to when used as an option. If it is unset, then the field may be freely used as an option on any kind of entity.

Signature

declare const FieldOptions_OptionTargetType: {
readonly TARGET_TYPE_ENUM: 6;
readonly TARGET_TYPE_ENUM_ENTRY: 7;
readonly TARGET_TYPE_EXTENSION_RANGE: 2;
readonly TARGET_TYPE_FIELD: 4;
readonly TARGET_TYPE_FILE: 1;
readonly TARGET_TYPE_MESSAGE: 3;
readonly TARGET_TYPE_METHOD: 9;
readonly TARGET_TYPE_ONEOF: 5;
readonly TARGET_TYPE_SERVICE: 8;
readonly TARGET_TYPE_UNKNOWN: 0;
}

A value of google.protobuf.FieldOptions.OptionTargetType.

Signature

type FieldOptions_OptionTargetType = typeof FieldOptions_OptionTargetType[keyof typeof FieldOptions_OptionTargetType]

The descriptor of google.protobuf.FileDescriptorProto.

Signature

declare const FileDescriptorProto: MessageDescriptor
Since v4.1.5

Describes a complete .proto file.

Signature

interface FileDescriptorProto {
readonly dependency?: readonly Array<string>;
readonly edition?: Edition;
readonly enum_type?: readonly Array<EnumDescriptorProto>;
readonly extension?: readonly Array<FieldDescriptorProto>;
readonly message_type?: readonly Array<DescriptorProto>;
readonly name?: string;
readonly option_dependency?: readonly Array<string>;
readonly options?: FileOptions;
readonly package?: string;
readonly public_dependency?: readonly Array<number>;
readonly service?: readonly Array<ServiceDescriptorProto>;
readonly source_code_info?: SourceCodeInfo;
readonly syntax?: string;
readonly weak_dependency?: readonly Array<number>;
}

The descriptor of google.protobuf.FileDescriptorSet.

Signature

declare const FileDescriptorSet: MessageDescriptor
Since v4.1.5

The protocol compiler can output a FileDescriptorSet containing the .proto files it parses.

Signature

interface FileDescriptorSet {
readonly file?: readonly Array<FileDescriptorProto>;
}

The descriptor of google.protobuf.FileOptions.

Signature

declare const FileOptions: MessageDescriptor

FileOptions

interface
Since v4.1.5

The fields of google.protobuf.FileOptions.

Signature

interface FileOptions {
readonly cc_enable_arenas?: boolean;
readonly cc_generic_services?: boolean;
readonly csharp_namespace?: string;
readonly deprecated?: boolean;
readonly features?: FeatureSet;
readonly go_package?: string;
readonly java_generate_equals_and_hash?: boolean;
readonly java_generic_services?: boolean;
readonly java_multiple_files?: boolean;
readonly java_outer_classname?: string;
readonly java_package?: string;
readonly java_string_check_utf8?: boolean;
readonly objc_class_prefix?: string;
readonly optimize_for?: FileOptions_OptimizeMode;
readonly php_class_prefix?: string;
readonly php_metadata_namespace?: string;
readonly php_namespace?: string;
readonly py_generic_services?: boolean;
readonly ruby_package?: string;
readonly swift_prefix?: string;
readonly uninterpreted_option?: readonly Array<UninterpretedOption>;
}

Generated classes can be optimized for speed or code size.

Signature

declare const FileOptions_OptimizeMode: {
readonly CODE_SIZE: 2;
readonly LITE_RUNTIME: 3;
readonly SPEED: 1;
}

A value of google.protobuf.FileOptions.OptimizeMode.

Signature

type FileOptions_OptimizeMode = typeof FileOptions_OptimizeMode[keyof typeof FileOptions_OptimizeMode]

The descriptor of google.protobuf.GeneratedCodeInfo.

Signature

declare const GeneratedCodeInfo: MessageDescriptor
Since v4.1.5

Describes the relationship between generated code and its original source file. A GeneratedCodeInfo message is associated with only one generated source file, but may contain references to different source .proto files.

Signature

interface GeneratedCodeInfo {
readonly annotation?: readonly Array<GeneratedCodeInfo_Annotation>;
}

The descriptor of google.protobuf.GeneratedCodeInfo.Annotation.

Signature

declare const GeneratedCodeInfo_Annotation: MessageDescriptor

The fields of google.protobuf.GeneratedCodeInfo.Annotation.

Signature

interface GeneratedCodeInfo_Annotation {
readonly begin?: number;
readonly end?: number;
readonly path?: readonly Array<number>;
readonly semantic?: GeneratedCodeInfo_Annotation_Semantic;
readonly source_file?: string;
}

Represents the identified object's effect on the element in the original .proto file.

Signature

declare const GeneratedCodeInfo_Annotation_Semantic: {
readonly ALIAS: 2;
readonly NONE: 0;
readonly SET: 1;
}

A value of google.protobuf.GeneratedCodeInfo.Annotation.Semantic.

Signature

type GeneratedCodeInfo_Annotation_Semantic = typeof GeneratedCodeInfo_Annotation_Semantic[keyof typeof GeneratedCodeInfo_Annotation_Semantic]

The descriptor of google.protobuf.MessageOptions.

Signature

declare const MessageOptions: MessageDescriptor
Since v4.1.5

The fields of google.protobuf.MessageOptions.

Signature

interface MessageOptions {
readonly deprecated?: boolean;
readonly deprecated_legacy_json_field_conflicts?: boolean;
readonly features?: FeatureSet;
readonly map_entry?: boolean;
readonly message_set_wire_format?: boolean;
readonly no_standard_descriptor_accessor?: boolean;
readonly uninterpreted_option?: readonly Array<UninterpretedOption>;
}

The descriptor of google.protobuf.MethodDescriptorProto.

Signature

declare const MethodDescriptorProto: MessageDescriptor
Since v4.1.5

Describes a method of a service.

Signature

interface MethodDescriptorProto {
readonly client_streaming?: boolean;
readonly input_type?: string;
readonly name?: string;
readonly options?: MethodOptions;
readonly output_type?: string;
readonly server_streaming?: boolean;
}

The descriptor of google.protobuf.MethodOptions.

Signature

declare const MethodOptions: MessageDescriptor

MethodOptions

interface
Since v4.1.5

The fields of google.protobuf.MethodOptions.

Signature

interface MethodOptions {
readonly deprecated?: boolean;
readonly features?: FeatureSet;
readonly idempotency_level?: MethodOptions_IdempotencyLevel;
readonly uninterpreted_option?: readonly Array<UninterpretedOption>;
}

Is this method side-effect-free (or safe in HTTP parlance), or idempotent, or neither? HTTP based RPC implementation may choose GET verb for safe methods, and PUT verb for idempotent methods instead of the default POST.

Signature

declare const MethodOptions_IdempotencyLevel: {
readonly IDEMPOTENCY_UNKNOWN: 0;
readonly IDEMPOTENT: 2;
readonly NO_SIDE_EFFECTS: 1;
}

A value of google.protobuf.MethodOptions.IdempotencyLevel.

Signature

type MethodOptions_IdempotencyLevel = typeof MethodOptions_IdempotencyLevel[keyof typeof MethodOptions_IdempotencyLevel]

The descriptor of google.protobuf.OneofDescriptorProto.

Signature

declare const OneofDescriptorProto: MessageDescriptor
Since v4.1.5

Describes a oneof.

Signature

interface OneofDescriptorProto {
readonly name?: string;
readonly options?: OneofOptions;
}

The descriptor of google.protobuf.OneofOptions.

Signature

declare const OneofOptions: MessageDescriptor

OneofOptions

interface
Since v4.1.5

The fields of google.protobuf.OneofOptions.

Signature

interface OneofOptions {
readonly features?: FeatureSet;
readonly uninterpreted_option?: readonly Array<UninterpretedOption>;
}

The descriptor of google.protobuf.ServiceDescriptorProto.

Signature

declare const ServiceDescriptorProto: MessageDescriptor
Since v4.1.5

Describes a service.

Signature

interface ServiceDescriptorProto {
readonly method?: readonly Array<MethodDescriptorProto>;
readonly name?: string;
readonly options?: ServiceOptions;
}

The descriptor of google.protobuf.ServiceOptions.

Signature

declare const ServiceOptions: MessageDescriptor
Since v4.1.5

The fields of google.protobuf.ServiceOptions.

Signature

interface ServiceOptions {
readonly deprecated?: boolean;
readonly features?: FeatureSet;
readonly uninterpreted_option?: readonly Array<UninterpretedOption>;
}

The descriptor of google.protobuf.SourceCodeInfo.

Signature

declare const SourceCodeInfo: MessageDescriptor
Since v4.1.5

Encapsulates information about the original source file from which a FileDescriptorProto was generated.

Signature

interface SourceCodeInfo {
readonly location?: readonly Array<SourceCodeInfo_Location>;
}

The descriptor of google.protobuf.SourceCodeInfo.Location.

Signature

declare const SourceCodeInfo_Location: MessageDescriptor
Since v4.1.5

The fields of google.protobuf.SourceCodeInfo.Location.

Signature

interface SourceCodeInfo_Location {
readonly leading_comments?: string;
readonly leading_detached_comments?: readonly Array<string>;
readonly path?: readonly Array<number>;
readonly span?: readonly Array<number>;
readonly trailing_comments?: string;
}

Describes the 'visibility' of a symbol with respect to the proto import system. Symbols can only be imported when the visibility rules do not prevent it (ex: local symbols cannot be imported). Visibility modifiers can only set on message and enum as they are the only types available to be referenced from other files.

Signature

declare const SymbolVisibility: {
readonly VISIBILITY_EXPORT: 2;
readonly VISIBILITY_LOCAL: 1;
readonly VISIBILITY_UNSET: 0;
}

A value of google.protobuf.SymbolVisibility.

Signature

type SymbolVisibility = typeof SymbolVisibility[keyof typeof SymbolVisibility]

The descriptor of google.protobuf.UninterpretedOption.

Signature

declare const UninterpretedOption: MessageDescriptor
Since v4.1.5

A message representing a option the parser does not recognize. This only appears in options protos created by the compiler::Parser class. DescriptorPool resolves these when building Descriptor objects. Therefore, options protos in descriptor objects (e.g. returned by Descriptor::options(), or produced by Descriptor::CopyTo()) will never have UninterpretedOptions in them.

Signature

interface UninterpretedOption {
readonly aggregate_value?: string;
readonly double_value?: number;
readonly identifier_value?: string;
readonly name?: readonly Array<UninterpretedOption_NamePart>;
readonly negative_int_value?: bigint;
readonly positive_int_value?: bigint;
readonly string_value?: Uint8Array<ArrayBufferLike>;
}

The descriptor of google.protobuf.UninterpretedOption.NamePart.

Signature

declare const UninterpretedOption_NamePart: MessageDescriptor

The name of the uninterpreted option. Each string represents a segment in a dot-separated name. is_extension is true iff a segment represents an extension (denoted with parentheses in options specs in .proto files). E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents "foo.(bar.baz).moo".

Signature

interface UninterpretedOption_NamePart {
readonly is_extension: boolean;
readonly name_part: string;
}

Errors

The error for descriptors that do not resolve, such as a missing dependency or type, or an unsupported edition.

Signature

declare class ProtobufDescriptorError extends YieldableError<this> & {
readonly _tag: "ProtobufDescriptorError";
} & Readonly<{
readonly message: string;
}> {
constructor(args: {
readonly message: string;
});
}

Models

Since v4.1.5

The editions this module resolves. proto2 and proto3 files are the editions of their syntax.

Signature

type EditionName = "proto2" | "proto3" | "2023" | "2024" | "2026"
Since v4.1.5

An enum type. An open enum holds any number; a closed enum holds only its values, and decoding keeps other numbers as unknown fields.

Signature

interface EnumDescriptor {
readonly _tag: "EnumDescriptor";
readonly file: FileDescriptor;
readonly name: string;
readonly open: boolean;
readonly parent: MessageDescriptor | undefined;
readonly proto: EnumDescriptorProto;
readonly typeName: string;
readonly values: readonly Array<EnumValueDescriptor>;
}
Since v4.1.5

A value of an enum.

Signature

interface EnumValueDescriptor {
readonly _tag: "EnumValueDescriptor";
readonly name: string;
readonly number: number;
readonly parent: EnumDescriptor;
readonly proto: EnumValueDescriptorProto;
}

EnumValueType

interface
Since v4.1.5

An enum value, held as its number.

Signature

interface EnumValueType {
readonly enum: EnumDescriptor;
readonly kind: "enum";
}
Since v4.1.5

An extension: a field of extendee declared outside of it.

Signature

interface ExtensionDescriptor {
readonly _tag: "ExtensionDescriptor";
readonly extendee: MessageDescriptor;
readonly field: SingularFieldDescriptor | ListFieldDescriptor;
readonly file: FileDescriptor;
readonly name: string;
readonly parent: MessageDescriptor | undefined;
readonly proto: FieldDescriptorProto;
readonly typeName: string;
}
Since v4.1.5

A field of a message, or of an extension.

Details

  • "singular": one value, present as its Presence says
  • "list": a repeated field, an array of values
  • "map": a map field, a record from keys to values

name is the property that holds the field in a message value: the original protobuf name, without casing changes or escaping.

Signature

type FieldDescriptor = SingularFieldDescriptor | ListFieldDescriptor | MapFieldDescriptor
Since v4.1.5

A resolved .proto file.

Signature

interface FileDescriptor {
readonly _tag: "FileDescriptor";
readonly dependencies: readonly Array<FileDescriptor>;
readonly edition: EditionName;
readonly enums: readonly Array<EnumDescriptor>;
readonly extensions: readonly Array<ExtensionDescriptor>;
readonly messages: readonly Array<MessageDescriptor>;
readonly name: string;
readonly package: string;
readonly proto: FileDescriptorProto;
readonly services: readonly Array<ServiceDescriptor>;
}
Since v4.1.5

How a value of a 64-bit integer field is held: a bigint, or a number or a decimal string, as [jstype = JS_NUMBER] and [jstype = JS_STRING] ask.

Signature

type JsType = "bigint" | "number" | "string"
Since v4.1.5

A repeated field. packed decides how number, boolean and enum elements are written; both encodings are read. Strings, bytes and messages are never packed.

Signature

interface ListFieldDescriptor extends FieldBase {
readonly kind: "list";
readonly packed: boolean;
readonly type: ValueType;
}
Since v4.1.5

A map field. key is a scalar type other than a float, double or bytes.

Signature

interface MapFieldDescriptor extends FieldBase {
readonly key: ScalarValueType;
readonly kind: "map";
readonly type: ValueType;
}
Since v4.1.5

A message type. fields are in declaration order. Map entry messages are not part of messages; their fields are described by the map field.

Signature

interface MessageDescriptor {
readonly _tag: "MessageDescriptor";
readonly enums: readonly Array<EnumDescriptor>;
readonly extensions: readonly Array<ExtensionDescriptor>;
readonly fields: readonly Array<FieldDescriptor>;
readonly file: FileDescriptor;
readonly messages: readonly Array<MessageDescriptor>;
readonly messageSetWireFormat: boolean;
readonly name: string;
readonly oneofs: readonly Array<OneofDescriptor>;
readonly parent: MessageDescriptor | undefined;
readonly proto: DescriptorProto;
readonly typeName: string;
}
Since v4.1.5

A message value. delimited messages are encoded as groups.

Signature

interface MessageValueType {
readonly delimited: boolean;
readonly kind: "message";
readonly message: MessageDescriptor;
}
Since v4.1.5

A method of a service.

Signature

interface MethodDescriptor {
readonly _tag: "MethodDescriptor";
readonly clientStreaming: boolean;
readonly idempotency: "unknown" | "noSideEffects" | "idempotent";
readonly input: MessageDescriptor;
readonly name: string;
readonly output: MessageDescriptor;
readonly parent: ServiceDescriptor;
readonly proto: MethodDescriptorProto;
readonly serverStreaming: boolean;
}
Since v4.1.5

A oneof. Synthetic oneofs, of proto3 optional fields, are not oneofs here: their fields have explicit presence.

Signature

interface OneofDescriptor {
readonly _tag: "OneofDescriptor";
readonly fields: readonly Array<FieldDescriptor>;
readonly name: string;
readonly parent: MessageDescriptor;
readonly proto: OneofDescriptorProto;
}
Since v4.1.5

When a singular field is present.

Details

  • "implicit": when it is not its zero value, as proto3 fields without optional
  • "explicit": when it is set, even to its zero value
  • "required": always, as proto2 required fields

Signature

type Presence = "implicit" | "explicit" | "required"

Registry

interface
Since v4.1.5

The resolved files of a set of .proto files, and their types by full name, such as "acme.v1.User".

Signature

interface Registry {
readonly files: readonly Array<FileDescriptor>;
readonly findExtension: (extendee: string, number: number) => ExtensionDescriptor | undefined;
readonly getEnum: (typeName: string) => EnumDescriptor | undefined;
readonly getExtension: (typeName: string) => ExtensionDescriptor | undefined;
readonly getFile: (name: string) => FileDescriptor | undefined;
readonly getMessage: (typeName: string) => MessageDescriptor | undefined;
readonly getService: (typeName: string) => ServiceDescriptor | undefined;
}
Since v4.1.5

The scalar types of protobuf fields.

Signature

type ScalarType = "double" | "float" | "int64" | "uint64" | "int32" | "fixed64" | "fixed32" | "bool" | "string" | "bytes" | "uint32" | "sfixed32" | "sfixed64" | "sint32" | "sint64"
Since v4.1.5

A scalar value. jsType applies to 64-bit integers, and validateUtf8 to strings.

Signature

interface ScalarValueType {
readonly jsType: JsType;
readonly kind: "scalar";
readonly scalar: ScalarType;
readonly validateUtf8: boolean;
}
Since v4.1.5

A service.

Signature

interface ServiceDescriptor {
readonly _tag: "ServiceDescriptor";
readonly file: FileDescriptor;
readonly methods: readonly Array<MethodDescriptor>;
readonly name: string;
readonly proto: ServiceDescriptorProto;
readonly typeName: string;
}
Since v4.1.5

A singular field.

Signature

interface SingularFieldDescriptor extends FieldBase {
readonly kind: "singular";
readonly presence: Presence;
readonly type: ValueType;
}
Since v4.1.5

The type of a value of a field: of a singular field, an element of a list, or a value of a map.

Signature

type ValueType = ScalarValueType | EnumValueType | MessageValueType