@grpc/proto-loader
- Version 0.7.13
- Published
- 120 kB
- 4 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
Interfaces
Enums
Type Aliases
Functions
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.
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 areNumber
andString
. Defaults to aLong
object type from a library.Parameter
options.enums The type that should be used to represent
enum
values. The only valid option isString
. Defaults to the numeric value.Parameter
options.bytes The type that should be used to represent
bytes
values. Valid options areArray
andString
. The default is to useBuffer
.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
isfalse
. Defaults tofalse
.Parameter
options.objects Set empty objects for missing object values even if
defaults
isfalse
. Defaults tofalse
.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: 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;
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 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;
Enums
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.
Badge
To add a badge like this oneto 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>
- Updated .
Package analyzed in 4002 ms. - Missing or incorrect documentation? Open an issue for this package.