Constructs a new reflected message type instance.
Parameters:
name |
string |
Message name |
options |
Object.<string, *> |
optional
Declared options |
Extends
Members
-
Comment text, if any.
-
ctor { Constructor.<{}> }
-
The registered constructor, if any registered, otherwise a generic constructor.
Assigning a function replaces the internal constructor. If the function does not extend Message yet, its prototype will be setup accordingly and static methods will be populated. If it already extends Message, it will just replace the internal constructor. -
Extension ranges, if any.
-
Message fields.
-
Fields of this message as an array for iteration.
-
Message fields by id.
-
Defining file name.
-
Full name including leading dot.
-
Unique name within its namespace.
-
nested { Object<string, ReflectionObject> | undefined }
-
Nested objects by name.
-
nestedArray readonly{ ReflectionObject[] }
-
Nested objects of this namespace as an array for iteration.
-
Oneofs declared within this namespace, if any.
-
Oneofs of this message as an array for iteration.
-
Options.
-
Parent namespace.
-
Parsed Options.
-
Reserved ranges, if any.
-
Whether already resolved or not.
-
Reference to the root namespace.
Methods
-
Adds a nested object to this type.
Parameters:
objectReflectionObject Nested object to add
Throws:
TypeError If arguments are invalid
Error If there is already a nested object with this name or, if a field, when there is already a field with this id
Returns:
Type this -
Adds nested objects to this namespace from nested object descriptors.
Parameters:
nestedJsonObject.<string, AnyNestedObject> Any nested object descriptors
depthnumber optional Current nesting depth, defaults to
0Returns:
Namespace this -
Creates a new message of this type using the specified properties.
Parameters:
propertiesObject.<string, *> optional Properties to set
Returns:
Message.<{}> Message instance -
Decodes a message of this type.
Parameters:
readerReader | Uint8Array Reader or buffer to decode from
lengthnumber optional Length of the message, if known beforehand
Throws:
Error If the payload is not a reader or valid buffer
util.ProtocolError.<{}> If required fields are missing
Returns:
Message.<{}> Decoded message -
Decodes a message of this type preceeded by its byte length as a varint.
Parameters:
readerReader | Uint8Array Reader or buffer to decode from
Throws:
Error If the payload is not a reader or valid buffer
util.ProtocolError If required fields are missing
Returns:
Message.<{}> Decoded message -
Defines additial namespaces within this one if not yet existing.
Parameters:
pathstring | Array.<string> Path to create
json* optional Nested types to create from JSON
Returns:
Namespace Pointer to the last namespace created or thisif path is empty -
Encodes a message of this type. Does not implicitly verify messages.
Parameters:
messageMessage.<{}> | Object.<string, *> Message instance or plain object
writerWriter optional Writer to encode to
Returns:
Writer writer -
Encodes a message of this type preceeded by its byte length as a varint. Does not implicitly verify messages.
Parameters:
messageMessage.<{}> | Object.<string, *> Message instance or plain object
writerWriter optional Writer to encode to
Returns:
Writer writer -
Creates a new message of this type from a plain object. Also converts values to their respective internal types.
Parameters:
objectObject.<string, *> Plain object to convert
Returns:
Message.<{}> Message instance -
inherited get(name){ ReflectionObject | null }
-
Gets the nested object of the specified name.
Parameters:
namestring Nested object name
Returns:
ReflectionObject | null The reflection object or nullif it doesn't exist -
inherited getEnum(name){ Object<string, number> }
-
Gets the values of the nested enum of the specified name.
This methods differs from get in that it returns an enum's values directly and throws instead of returningnull.Parameters:
namestring Nested enum name
Throws:
Error If there is no such enum
Returns:
Object.<string, number> Enum values -
Gets an option value.
Parameters:
namestring Option name
Returns:
* Option value or undefinedif not set -
Gets the type url for this type.
Parameters:
prefixstring optional Custom type url prefix, defaults to
"type.googleapis.com"Returns:
string The type url -
Tests if the specified id is reserved.
Parameters:
idnumber Id to test
Returns:
boolean trueif reserved, otherwisefalse -
Tests if the specified name is reserved.
Parameters:
namestring Name to test
Returns:
boolean trueif reserved, otherwisefalse -
inherited lookup(path, filterTypes, parentAlreadyChecked){ ReflectionObject | null }
-
Recursively looks up the reflection object matching the specified path in the scope of this namespace.
Parameters:
pathstring | Array.<string> Path to look up
filterTypes* | Array.<*> Filter types, any combination of the constructors of
protobuf.Type,protobuf.Enum,protobuf.Serviceetc.parentAlreadyCheckedboolean false optional If known, whether the parent has already been checked
Returns:
ReflectionObject | null Looked up object or nullif none could be found -
inherited lookup(path, parentAlreadyChecked){ ReflectionObject | null }
-
Looks up the reflection object at the specified path, relative to this namespace.
Parameters:
pathstring | Array.<string> Path to look up
parentAlreadyCheckedboolean false optional Whether the parent has already been checked
Returns:
ReflectionObject | null Looked up object or nullif none could be found -
Looks up the values of the enum at the specified path, relative to this namespace.
Besides its signature, this methods differs from lookup in that it throws instead of returningnull.Parameters:
pathstring | Array.<string> Path to look up
Throws:
Error If
pathdoes not point to an enumReturns:
Enum Looked up enum -
Looks up the service at the specified path, relative to this namespace.
Besides its signature, this methods differs from lookup in that it throws instead of returningnull.Parameters:
pathstring | Array.<string> Path to look up
Throws:
Error If
pathdoes not point to a serviceReturns:
Service Looked up service -
Looks up the type at the specified path, relative to this namespace.
Besides its signature, this methods differs from lookup in that it throws instead of returningnull.Parameters:
pathstring | Array.<string> Path to look up
Throws:
Error If
pathdoes not point to a typeReturns:
Type Looked up type -
Looks up the type or enum at the specified path, relative to this namespace.
Besides its signature, this methods differs from lookup in that it throws instead of returningnull.Parameters:
pathstring | Array.<string> Path to look up
Throws:
Error If
pathdoes not point to a type or enumReturns:
Type Looked up type or enum -
Called when this object is added to a parent.
Parameters:
parentReflectionObject Parent added to
Returns:
undefined -
Called when this object is removed from a parent.
Parameters:
parentReflectionObject Parent removed from
Returns:
undefined -
Removes a nested object from this type.
Parameters:
objectReflectionObject Nested object to remove
Throws:
TypeError If arguments are invalid
Error If
objectis not a member of this typeReturns:
Type this -
inherited resolve(){ ReflectionObject }
-
Resolves this objects type references.
Returns:
ReflectionObject this -
Resolves this namespace's and all its nested objects' type references. Useful to validate a reflection tree, but comes at a cost.
Returns:
Namespace this -
inherited setOption(name, value, ifNotSet){ ReflectionObject }
-
Sets an option.
Parameters:
namestring Option name
value* Option value
ifNotSetboolean | undefined optional Sets the option only if it isn't currently set
Returns:
ReflectionObject this -
inherited setOptions(options, ifNotSet){ ReflectionObject }
-
Sets multiple options.
Parameters:
optionsObject.<string, *> Options to set
ifNotSetboolean optional Sets an option only if it isn't currently set
Returns:
ReflectionObject this -
inherited setParsedOption(name, value, propName){ ReflectionObject }
-
Sets a parsed option.
Parameters:
namestring parsed Option name
value* Option value
propNamestring dot '.' delimited full path of property within the option to set. if undefined\empty, will add a new option with that value
Returns:
ReflectionObject this -
Returns:
Type this -
Converts this message type to a message type descriptor.
Parameters:
toJSONOptionsIToJSONOptions optional JSON conversion options
Returns:
IType Message type descriptor -
Creates a plain object from a message of this type. Also converts values to other types if specified.
Parameters:
messageMessage.<{}> Message instance
optionsIConversionOptions optional Conversion options
Returns:
Object.<string, *> Plain object -
Converts this instance to its string representation.
Returns:
string Class name[, space, full name] -
Verifies that field values are valid and that required fields are present.
Parameters:
messageObject.<string, *> Plain object to verify
Returns:
null | string nullif valid, otherwise the reason why it is not -
Type.d(typeName){ TypeDecorator.<T> }
-
Type decorator (TypeScript).
Parameters:
typeNamestring optional Type name, defaults to the constructor's name
Deprecated:
Returns:
TypeDecorator.<T> Decorator function -
Creates a message type from a message type descriptor.
Parameters:
namestring Message name
jsonIType Message type descriptor
depthnumber optional Current nesting depth, defaults to
0Returns:
Type Created message type -
Generates a constructor function for the specified type.
Parameters:
mtypeType Message type
Returns:
Codegen Codegen instance