• Version 0.7.13
  • Published
  • 120 kB
  • 4 dependencies
  • Apache-2.0 license


npm i @grpc/proto-loader
yarn add @grpc/proto-loader
pnpm add @grpc/proto-loader


gRPC utility library for loading .proto files



function fromJSON

fromJSON: (json: Protobuf.INamespace, options?: Options) => PackageDefinition;

    function isAnyExtension

    isAnyExtension: (obj: object) => obj is AnyExtension;

      function load

      load: (
      filename: string | string[],
      options?: Options
      ) => Promise<PackageDefinition>;
      • Load a .proto file with the specified options.

        Parameter filename

        One or multiple file paths to load. Can be an absolute path or relative to an include path.


        options.keepCase Preserve field names. The default is to change them to camel case.


        options.longs The type that should be used to represent long values. Valid options are Number and String. Defaults to a Long object type from a library.


        options.enums The type that should be used to represent enum values. The only valid option is String. Defaults to the numeric value.


        options.bytes The type that should be used to represent bytes values. Valid options are Array and String. The default is to use Buffer.


        options.defaults Set default values on output objects. Defaults to false.


        options.arrays Set empty arrays for missing array values even if defaults is false. Defaults to false.


        options.objects Set empty objects for missing object values even if defaults is false. Defaults to false.


        options.oneofs Set virtual oneof properties to the present field's name


        options.json Represent Infinity and NaN as strings in float fields, and automatically decode google.protobuf.Any values.


        options.includeDirs Paths to search for imported .proto files.

      function loadFileDescriptorSetFromBuffer

      loadFileDescriptorSetFromBuffer: (
      descriptorSet: Buffer,
      options?: Options
      ) => PackageDefinition;

        function loadFileDescriptorSetFromObject

        loadFileDescriptorSetFromObject: (
        descriptorSet: Parameters<typeof descriptor.FileDescriptorSet.fromObject>[0],
        options?: Options
        ) => PackageDefinition;

          function loadSync

          loadSync: (filename: string | string[], options?: Options) => PackageDefinition;


            interface AnyExtension

            interface AnyExtension {}
            • This type exists for use with code generated by the proto-loader-gen-types tool. This type should be used with another interface, e.g. MessageType & AnyExtension for an object that is converted to or from a google.protobuf.Any message. For example, when processing an Any message:

              if (isAnyExtension(message)) {
              switch (message['@type']) {
              case TYPE1_URL:
              handleType1(message as AnyExtension & Type1);
              case TYPE2_URL:
              handleType2(message as AnyExtension & Type2);
              // ...

            property '@type'

            '@type': string;
            • The fully qualified name of the message type that this object represents, possibly including a URL prefix.

            interface Deserialize

            interface Deserialize<T> {}

              call signature

              (bytes: Buffer): T;

                interface EnumTypeDefinition

                interface EnumTypeDefinition extends ProtobufTypeDefinition {}

                  property format

                  format: 'Protocol Buffer 3 EnumDescriptorProto';

                    interface MessageTypeDefinition

                    interface MessageTypeDefinition extends ProtobufTypeDefinition {}

                      property format

                      format: 'Protocol Buffer 3 DescriptorProto';

                        interface MethodDefinition

                        interface MethodDefinition<
                        OutputRequestType = RequestType,
                        OutputResponseType = ResponseType
                        > {}

                          property options

                          options: MethodOptions;

                            property originalName

                            originalName?: string;

                              property path

                              path: string;

                                property requestDeserialize

                                requestDeserialize: Deserialize<OutputRequestType>;

                                  property requestSerialize

                                  requestSerialize: Serialize<RequestType>;

                                    property requestStream

                                    requestStream: boolean;

                                      property requestType

                                      requestType: MessageTypeDefinition;

                                        property responseDeserialize

                                        responseDeserialize: Deserialize<OutputResponseType>;

                                          property responseSerialize

                                          responseSerialize: Serialize<ResponseType>;

                                            property responseStream

                                            responseStream: boolean;

                                              property responseType

                                              responseType: MessageTypeDefinition;

                                                interface MethodOptions

                                                interface MethodOptions {}

                                                  property deprecated

                                                  deprecated: boolean;

                                                    property idempotency_level

                                                    idempotency_level: IdempotencyLevel;

                                                      property uninterpreted_option

                                                      uninterpreted_option: UninterpretedOption[];

                                                        index signature

                                                        [k: string]: unknown;

                                                          interface NamePart

                                                          interface NamePart {}

                                                            property is_extension

                                                            is_extension: boolean;

                                                              property name_part

                                                              name_part: string;

                                                                interface PackageDefinition

                                                                interface PackageDefinition {}

                                                                  index signature

                                                                  [index: string]: AnyDefinition;

                                                                    interface ProtobufTypeDefinition

                                                                    interface ProtobufTypeDefinition {}

                                                                      property fileDescriptorProtos

                                                                      fileDescriptorProtos: Buffer[];

                                                                        property format

                                                                        format: string;

                                                                          property type

                                                                          type: object;

                                                                            interface Serialize

                                                                            interface Serialize<T> {}

                                                                              call signature

                                                                              (value: T): Buffer;

                                                                                interface ServiceDefinition

                                                                                interface ServiceDefinition {}

                                                                                  index signature

                                                                                  [index: string]: MethodDefinition<object, object>;

                                                                                    interface UninterpretedOption

                                                                                    interface UninterpretedOption {}

                                                                                      property aggregate_value

                                                                                      aggregate_value?: string;

                                                                                        property double_value

                                                                                        double_value?: number;

                                                                                          property identifier_value

                                                                                          identifier_value?: string;

                                                                                            property name

                                                                                            name?: NamePart[];

                                                                                              property negative_int_value

                                                                                              negative_int_value?: number;

                                                                                                property positive_int_value

                                                                                                positive_int_value?: number;

                                                                                                  property string_value

                                                                                                  string_value?: string;


                                                                                                    enum IdempotencyLevel

                                                                                                    enum IdempotencyLevel {
                                                                                                    IDEMPOTENCY_UNKNOWN = 'IDEMPOTENCY_UNKNOWN',
                                                                                                    NO_SIDE_EFFECTS = 'NO_SIDE_EFFECTS',
                                                                                                    IDEMPOTENT = 'IDEMPOTENT',

                                                                                                      member IDEMPOTENCY_UNKNOWN

                                                                                                      IDEMPOTENCY_UNKNOWN = 'IDEMPOTENCY_UNKNOWN'

                                                                                                        member IDEMPOTENT

                                                                                                        IDEMPOTENT = 'IDEMPOTENT'

                                                                                                          member NO_SIDE_EFFECTS

                                                                                                          NO_SIDE_EFFECTS = 'NO_SIDE_EFFECTS'

                                                                                                            Type Aliases

                                                                                                            type AnyDefinition

                                                                                                            type AnyDefinition = ServiceDefinition | MessageTypeDefinition | EnumTypeDefinition;

                                                                                                              type Options

                                                                                                              type Options = Protobuf.IParseOptions &
                                                                                                              Protobuf.IConversionOptions & {
                                                                                                              includeDirs?: string[];

                                                                                                                Package Files (2)

                                                                                                                Dependencies (4)

                                                                                                                Dev Dependencies (11)

                                                                                                                Peer Dependencies (0)

                                                                                                                No peer dependencies.


                                                                                                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@grpc/proto-loader.

                                                                                                                • Markdown
                                                                                                                • HTML
                                                                                                                  <a href="https://www.jsdocs.io/package/@grpc/proto-loader"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>