@grpc/proto-loader

  • Version 0.6.2
  • Published
  • 70.5 kB
  • 5 dependencies
  • Apache-2.0 license

Install

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

Overview

gRPC utility library for loading .proto files

Index

Functions

function fromJSON

fromJSON: (json: any, 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.

        Parameter

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

        Parameter

        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.

        Parameter

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

        Parameter

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

        Parameter

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

        Parameter

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

        Parameter

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

        Parameter

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

        Parameter

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

        Parameter

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

      function loadFileDescriptorSetFromBuffer

      loadFileDescriptorSetFromBuffer: (
      descriptorSet: any,
      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;

            Interfaces

            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);
              break;
              case TYPE2_URL:
              handleType2(message as AnyExtension & Type2);
              break;
              // ...
              }
              }

            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<
                        RequestType,
                        ResponseType,
                        OutputRequestType = RequestType,
                        OutputResponseType = ResponseType
                        > {}

                          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 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>;

                                                                  Type Aliases

                                                                  type AnyDefinition

                                                                  type AnyDefinition = ServiceDefinition | MessageTypeDefinition | EnumTypeDefinition;

                                                                    type Options

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

                                                                      Package Files (2)

                                                                      Dependencies (5)

                                                                      Dev Dependencies (9)

                                                                      Peer Dependencies (0)

                                                                      No peer dependencies.

                                                                      Badge

                                                                      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
                                                                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@grpc/proto-loader)
                                                                      • 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>