CoolFace
Apppublic

HarshvardhanCn01/Voice-Assistant

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
index.d.ts2742 linesDownload Raw Back to protobufjs
1// DO NOT EDIT! This is a generated file. Edit the JSDoc in src/*.js instead and run 'npm run build:types'.2 3export as namespace protobuf;4 5/**6 * Provides common type definitions.7 * Can also be used to provide additional google types or your own custom types.8 * @param name Short name as in `google/protobuf/[name].proto` or full file name9 * @param json JSON definition within `google.protobuf` if a short name, otherwise the file's root definition10 */11export function common(name: string, json: { [k: string]: any }): void;12 13export namespace common {14 15    /** Properties of a google.protobuf.Any message. */16    interface IAny {17        typeUrl?: string;18        bytes?: Uint8Array;19    }20 21    /** Properties of a google.protobuf.Duration message. */22    interface IDuration {23        seconds?: (number|Long);24        nanos?: number;25    }26 27    /** Properties of a google.protobuf.Timestamp message. */28    interface ITimestamp {29        seconds?: (number|Long);30        nanos?: number;31    }32 33    /** Properties of a google.protobuf.Empty message. */34    interface IEmpty {35    }36 37    /** Properties of a google.protobuf.Struct message. */38    interface IStruct {39        fields?: { [k: string]: IValue };40    }41 42    /** Properties of a google.protobuf.Value message. */43    interface IValue {44        kind?: string;45        nullValue?: 0;46        numberValue?: number;47        stringValue?: string;48        boolValue?: boolean;49        structValue?: IStruct;50        listValue?: IListValue;51    }52 53    /** Properties of a google.protobuf.ListValue message. */54    interface IListValue {55        values?: IValue[];56    }57 58    /** Properties of a google.protobuf.DoubleValue message. */59    interface IDoubleValue {60        value?: number;61    }62 63    /** Properties of a google.protobuf.FloatValue message. */64    interface IFloatValue {65        value?: number;66    }67 68    /** Properties of a google.protobuf.Int64Value message. */69    interface IInt64Value {70        value?: (number|Long);71    }72 73    /** Properties of a google.protobuf.UInt64Value message. */74    interface IUInt64Value {75        value?: (number|Long);76    }77 78    /** Properties of a google.protobuf.Int32Value message. */79    interface IInt32Value {80        value?: number;81    }82 83    /** Properties of a google.protobuf.UInt32Value message. */84    interface IUInt32Value {85        value?: number;86    }87 88    /** Properties of a google.protobuf.BoolValue message. */89    interface IBoolValue {90        value?: boolean;91    }92 93    /** Properties of a google.protobuf.StringValue message. */94    interface IStringValue {95        value?: string;96    }97 98    /** Properties of a google.protobuf.BytesValue message. */99    interface IBytesValue {100        value?: Uint8Array;101    }102 103    /**104     * Gets the root definition of the specified common proto file.105     *106     * Bundled definitions are:107     * - google/protobuf/any.proto108     * - google/protobuf/duration.proto109     * - google/protobuf/empty.proto110     * - google/protobuf/field_mask.proto111     * - google/protobuf/struct.proto112     * - google/protobuf/timestamp.proto113     * - google/protobuf/wrappers.proto114     *115     * @param file Proto file name116     * @returns Root definition or `null` if not defined117     */118    function get(file: string): (INamespace|null);119}120 121/** Runtime message from/to plain object converters. */122export namespace converter {123 124    /**125     * Generates a plain object to runtime message converter specific to the specified message type.126     * @param mtype Message type127     * @returns Codegen instance128     */129    function fromObject(mtype: Type): Codegen;130 131    /**132     * Generates a runtime message to plain object converter specific to the specified message type.133     * @param mtype Message type134     * @returns Codegen instance135     */136    function toObject(mtype: Type): Codegen;137}138 139/**140 * Generates a decoder specific to the specified message type.141 * @param mtype Message type142 * @returns Codegen instance143 */144export function decoder(mtype: Type): Codegen;145 146/**147 * Generates an encoder specific to the specified message type.148 * @param mtype Message type149 * @returns Codegen instance150 */151export function encoder(mtype: Type): Codegen;152 153/** Reflected enum. */154export class Enum extends ReflectionObject {155 156    /**157     * Constructs a new enum instance.158     * @param name Unique name within its namespace159     * @param [values] Enum values as an object, by name160     * @param [options] Declared options161     * @param [comment] The comment for this enum162     * @param [comments] The value comments for this enum163     * @param [valuesOptions] The value options for this enum164     */165    constructor(name: string, values?: { [k: string]: number }, options?: { [k: string]: any }, comment?: string, comments?: { [k: string]: string }, valuesOptions?: ({ [k: string]: { [k: string]: any } }|undefined));166 167    /** Enum values by id. */168    public valuesById: { [k: number]: string };169 170    /** Enum values by name. */171    public values: { [k: string]: number };172 173    /** Enum comment text. */174    public comment: (string|null);175 176    /** Value comment texts, if any. */177    public comments: { [k: string]: string };178 179    /** Values options, if any */180    public valuesOptions?: { [k: string]: { [k: string]: any } };181 182    /** Reserved ranges, if any. */183    public reserved: (number[]|string)[];184 185    /**186     * Constructs an enum from an enum descriptor.187     * @param name Enum name188     * @param json Enum descriptor189     * @returns Created enum190     * @throws {TypeError} If arguments are invalid191     */192    public static fromJSON(name: string, json: IEnum): Enum;193 194    /**195     * Converts this enum to an enum descriptor.196     * @param [toJSONOptions] JSON conversion options197     * @returns Enum descriptor198     */199    public toJSON(toJSONOptions?: IToJSONOptions): IEnum;200 201    /**202     * Adds a value to this enum.203     * @param name Value name204     * @param id Value id205     * @param [comment] Comment, if any206     * @param {Object.<string, *>|undefined} [options] Options, if any207     * @returns `this`208     * @throws {TypeError} If arguments are invalid209     * @throws {Error} If there is already a value with this name or id210     */211    public add(name: string, id: number, comment?: string, options?: ({ [k: string]: any }|undefined)): Enum;212 213    /**214     * Removes a value from this enum215     * @param name Value name216     * @returns `this`217     * @throws {TypeError} If arguments are invalid218     * @throws {Error} If `name` is not a name of this enum219     */220    public remove(name: string): Enum;221 222    /**223     * Tests if the specified id is reserved.224     * @param id Id to test225     * @returns `true` if reserved, otherwise `false`226     */227    public isReservedId(id: number): boolean;228 229    /**230     * Tests if the specified name is reserved.231     * @param name Name to test232     * @returns `true` if reserved, otherwise `false`233     */234    public isReservedName(name: string): boolean;235}236 237/** Enum descriptor. */238export interface IEnum {239 240    /** Enum values */241    values: { [k: string]: number };242 243    /** Enum options */244    options?: { [k: string]: any };245}246 247/** Reflected message field. */248export class Field extends FieldBase {249 250    /**251     * Constructs a new message field instance. Note that {@link MapField|map fields} have their own class.252     * @param name Unique name within its namespace253     * @param id Unique id within its namespace254     * @param type Value type255     * @param [rule="optional"] Field rule256     * @param [extend] Extended type if different from parent257     * @param [options] Declared options258     */259    constructor(name: string, id: number, type: string, rule?: (string|{ [k: string]: any }), extend?: (string|{ [k: string]: any }), options?: { [k: string]: any });260 261    /**262     * Constructs a field from a field descriptor.263     * @param name Field name264     * @param json Field descriptor265     * @returns Created field266     * @throws {TypeError} If arguments are invalid267     */268    public static fromJSON(name: string, json: IField): Field;269 270    /** Determines whether this field is packed. Only relevant when repeated and working with proto2. */271    public readonly packed: boolean;272 273    /**274     * Field decorator (TypeScript).275     * @param fieldId Field id276     * @param fieldType Field type277     * @param [fieldRule="optional"] Field rule278     * @param [defaultValue] Default value279     * @returns Decorator function280     */281    public static d<T extends number | number[] | Long | Long[] | string | string[] | boolean | boolean[] | Uint8Array | Uint8Array[] | Buffer | Buffer[]>(fieldId: number, fieldType: ("double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"string"|"bool"|"bytes"|object), fieldRule?: ("optional"|"required"|"repeated"), defaultValue?: T): FieldDecorator;282 283    /**284     * Field decorator (TypeScript).285     * @param fieldId Field id286     * @param fieldType Field type287     * @param [fieldRule="optional"] Field rule288     * @returns Decorator function289     */290    public static d<T extends Message<T>>(fieldId: number, fieldType: (Constructor<T>|string), fieldRule?: ("optional"|"required"|"repeated")): FieldDecorator;291}292 293/** Base class of all reflected message fields. This is not an actual class but here for the sake of having consistent type definitions. */294export class FieldBase extends ReflectionObject {295 296    /**297     * Not an actual constructor. Use {@link Field} instead.298     * @param name Unique name within its namespace299     * @param id Unique id within its namespace300     * @param type Value type301     * @param [rule="optional"] Field rule302     * @param [extend] Extended type if different from parent303     * @param [options] Declared options304     * @param [comment] Comment associated with this field305     */306    constructor(name: string, id: number, type: string, rule?: (string|{ [k: string]: any }), extend?: (string|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string);307 308    /** Field type. */309    public type: string;310 311    /** Unique field id. */312    public id: number;313 314    /** Extended type if different from parent. */315    public extend?: string;316 317    /** Whether this field is required. */318    public required: boolean;319 320    /** Whether this field is optional. */321    public optional: boolean;322 323    /** Whether this field is repeated. */324    public repeated: boolean;325 326    /** Whether this field is a map or not. */327    public map: boolean;328 329    /** Message this field belongs to. */330    public message: (Type|null);331 332    /** OneOf this field belongs to, if any, */333    public partOf: (OneOf|null);334 335    /** The field type's default value. */336    public typeDefault: any;337 338    /** The field's default value on prototypes. */339    public defaultValue: any;340 341    /** Whether this field's value should be treated as a long. */342    public long: boolean;343 344    /** Whether this field's value is a buffer. */345    public bytes: boolean;346 347    /** Resolved type if not a basic type. */348    public resolvedType: (Type|Enum|null);349 350    /** Sister-field within the extended type if a declaring extension field. */351    public extensionField: (Field|null);352 353    /** Sister-field within the declaring namespace if an extended field. */354    public declaringField: (Field|null);355 356    /** Comment for this field. */357    public comment: (string|null);358 359    /**360     * Converts this field to a field descriptor.361     * @param [toJSONOptions] JSON conversion options362     * @returns Field descriptor363     */364    public toJSON(toJSONOptions?: IToJSONOptions): IField;365 366    /**367     * Resolves this field's type references.368     * @returns `this`369     * @throws {Error} If any reference cannot be resolved370     */371    public resolve(): Field;372}373 374/** Field descriptor. */375export interface IField {376 377    /** Field rule */378    rule?: string;379 380    /** Field type */381    type: string;382 383    /** Field id */384    id: number;385 386    /** Field options */387    options?: { [k: string]: any };388}389 390/** Extension field descriptor. */391export interface IExtensionField extends IField {392 393    /** Extended type */394    extend: string;395}396 397/**398 * Decorator function as returned by {@link Field.d} and {@link MapField.d} (TypeScript).399 * @param prototype Target prototype400 * @param fieldName Field name401 */402type FieldDecorator = (prototype: object, fieldName: string) => void;403 404/**405 * A node-style callback as used by {@link load} and {@link Root#load}.406 * @param error Error, if any, otherwise `null`407 * @param [root] Root, if there hasn't been an error408 */409type LoadCallback = (error: (Error|null), root?: Root) => void;410 411/**412 * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.413 * @param filename One or multiple files to load414 * @param root Root namespace, defaults to create a new one if omitted.415 * @param callback Callback function416 * @see {@link Root#load}417 */418export function load(filename: (string|string[]), root: Root, callback: LoadCallback): void;419 420/**421 * Loads one or multiple .proto or preprocessed .json files into a common root namespace and calls the callback.422 * @param filename One or multiple files to load423 * @param callback Callback function424 * @see {@link Root#load}425 */426export function load(filename: (string|string[]), callback: LoadCallback): void;427 428/**429 * Loads one or multiple .proto or preprocessed .json files into a common root namespace and returns a promise.430 * @param filename One or multiple files to load431 * @param [root] Root namespace, defaults to create a new one if omitted.432 * @returns Promise433 * @see {@link Root#load}434 */435export function load(filename: (string|string[]), root?: Root): Promise<Root>;436 437/**438 * Synchronously loads one or multiple .proto or preprocessed .json files into a common root namespace (node only).439 * @param filename One or multiple files to load440 * @param [root] Root namespace, defaults to create a new one if omitted.441 * @returns Root namespace442 * @throws {Error} If synchronous fetching is not supported (i.e. in browsers) or if a file's syntax is invalid443 * @see {@link Root#loadSync}444 */445export function loadSync(filename: (string|string[]), root?: Root): Root;446 447/** Build type, one of `"full"`, `"light"` or `"minimal"`. */448export const build: string;449 450/** Reconfigures the library according to the environment. */451export function configure(): void;452 453/** Reflected map field. */454export class MapField extends FieldBase {455 456    /**457     * Constructs a new map field instance.458     * @param name Unique name within its namespace459     * @param id Unique id within its namespace460     * @param keyType Key type461     * @param type Value type462     * @param [options] Declared options463     * @param [comment] Comment associated with this field464     */465    constructor(name: string, id: number, keyType: string, type: string, options?: { [k: string]: any }, comment?: string);466 467    /** Key type. */468    public keyType: string;469 470    /** Resolved key type if not a basic type. */471    public resolvedKeyType: (ReflectionObject|null);472 473    /**474     * Constructs a map field from a map field descriptor.475     * @param name Field name476     * @param json Map field descriptor477     * @returns Created map field478     * @throws {TypeError} If arguments are invalid479     */480    public static fromJSON(name: string, json: IMapField): MapField;481 482    /**483     * Converts this map field to a map field descriptor.484     * @param [toJSONOptions] JSON conversion options485     * @returns Map field descriptor486     */487    public toJSON(toJSONOptions?: IToJSONOptions): IMapField;488 489    /**490     * Map field decorator (TypeScript).491     * @param fieldId Field id492     * @param fieldKeyType Field key type493     * @param fieldValueType Field value type494     * @returns Decorator function495     */496    public static d<T extends { [key: string]: number | Long | string | boolean | Uint8Array | Buffer | number[] | Message<{}> }>(fieldId: number, fieldKeyType: ("int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"), fieldValueType: ("double"|"float"|"int32"|"uint32"|"sint32"|"fixed32"|"sfixed32"|"int64"|"uint64"|"sint64"|"fixed64"|"sfixed64"|"bool"|"string"|"bytes"|object|Constructor<{}>)): FieldDecorator;497}498 499/** Map field descriptor. */500export interface IMapField extends IField {501 502    /** Key type */503    keyType: string;504}505 506/** Extension map field descriptor. */507export interface IExtensionMapField extends IMapField {508 509    /** Extended type */510    extend: string;511}512 513/** Abstract runtime message. */514export class Message<T extends object = object> {515 516    /**517     * Constructs a new message instance.518     * @param [properties] Properties to set519     */520    constructor(properties?: Properties<T>);521 522    /** Reference to the reflected type. */523    public static readonly $type: Type;524 525    /** Reference to the reflected type. */526    public readonly $type: Type;527 528    /**529     * Creates a new message of this type using the specified properties.530     * @param [properties] Properties to set531     * @returns Message instance532     */533    public static create<T extends Message<T>>(this: Constructor<T>, properties?: { [k: string]: any }): Message<T>;534 535    /**536     * Encodes a message of this type.537     * @param message Message to encode538     * @param [writer] Writer to use539     * @returns Writer540     */541    public static encode<T extends Message<T>>(this: Constructor<T>, message: (T|{ [k: string]: any }), writer?: Writer): Writer;542 543    /**544     * Encodes a message of this type preceeded by its length as a varint.545     * @param message Message to encode546     * @param [writer] Writer to use547     * @returns Writer548     */549    public static encodeDelimited<T extends Message<T>>(this: Constructor<T>, message: (T|{ [k: string]: any }), writer?: Writer): Writer;550 551    /**552     * Decodes a message of this type.553     * @param reader Reader or buffer to decode554     * @returns Decoded message555     */556    public static decode<T extends Message<T>>(this: Constructor<T>, reader: (Reader|Uint8Array)): T;557 558    /**559     * Decodes a message of this type preceeded by its length as a varint.560     * @param reader Reader or buffer to decode561     * @returns Decoded message562     */563    public static decodeDelimited<T extends Message<T>>(this: Constructor<T>, reader: (Reader|Uint8Array)): T;564 565    /**566     * Verifies a message of this type.567     * @param message Plain object to verify568     * @returns `null` if valid, otherwise the reason why it is not569     */570    public static verify(message: { [k: string]: any }): (string|null);571 572    /**573     * Creates a new message of this type from a plain object. Also converts values to their respective internal types.574     * @param object Plain object575     * @returns Message instance576     */577    public static fromObject<T extends Message<T>>(this: Constructor<T>, object: { [k: string]: any }): T;578 579    /**580     * Creates a plain object from a message of this type. Also converts values to other types if specified.581     * @param message Message instance582     * @param [options] Conversion options583     * @returns Plain object584     */585    public static toObject<T extends Message<T>>(this: Constructor<T>, message: T, options?: IConversionOptions): { [k: string]: any };586 587    /**588     * Converts this message to JSON.589     * @returns JSON object590     */591    public toJSON(): { [k: string]: any };592}593 594/** Reflected service method. */595export class Method extends ReflectionObject {596 597    /**598     * Constructs a new service method instance.599     * @param name Method name600     * @param type Method type, usually `"rpc"`601     * @param requestType Request message type602     * @param responseType Response message type603     * @param [requestStream] Whether the request is streamed604     * @param [responseStream] Whether the response is streamed605     * @param [options] Declared options606     * @param [comment] The comment for this method607     * @param [parsedOptions] Declared options, properly parsed into an object608     */609    constructor(name: string, type: (string|undefined), requestType: string, responseType: string, requestStream?: (boolean|{ [k: string]: any }), responseStream?: (boolean|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string, parsedOptions?: { [k: string]: any });610 611    /** Method type. */612    public type: string;613 614    /** Request type. */615    public requestType: string;616 617    /** Whether requests are streamed or not. */618    public requestStream?: boolean;619 620    /** Response type. */621    public responseType: string;622 623    /** Whether responses are streamed or not. */624    public responseStream?: boolean;625 626    /** Resolved request type. */627    public resolvedRequestType: (Type|null);628 629    /** Resolved response type. */630    public resolvedResponseType: (Type|null);631 632    /** Comment for this method */633    public comment: (string|null);634 635    /** Options properly parsed into an object */636    public parsedOptions: any;637 638    /**639     * Constructs a method from a method descriptor.640     * @param name Method name641     * @param json Method descriptor642     * @returns Created method643     * @throws {TypeError} If arguments are invalid644     */645    public static fromJSON(name: string, json: IMethod): Method;646 647    /**648     * Converts this method to a method descriptor.649     * @param [toJSONOptions] JSON conversion options650     * @returns Method descriptor651     */652    public toJSON(toJSONOptions?: IToJSONOptions): IMethod;653}654 655/** Method descriptor. */656export interface IMethod {657 658    /** Method type */659    type?: string;660 661    /** Request type */662    requestType: string;663 664    /** Response type */665    responseType: string;666 667    /** Whether requests are streamed */668    requestStream?: boolean;669 670    /** Whether responses are streamed */671    responseStream?: boolean;672 673    /** Method options */674    options?: { [k: string]: any };675 676    /** Method comments */677    comment: string;678 679    /** Method options properly parsed into an object */680    parsedOptions?: { [k: string]: any };681}682 683/** Reflected namespace. */684export class Namespace extends NamespaceBase {685 686    /**687     * Constructs a new namespace instance.688     * @param name Namespace name689     * @param [options] Declared options690     */691    constructor(name: string, options?: { [k: string]: any });692 693    /**694     * Constructs a namespace from JSON.695     * @param name Namespace name696     * @param json JSON object697     * @returns Created namespace698     * @throws {TypeError} If arguments are invalid699     */700    public static fromJSON(name: string, json: { [k: string]: any }): Namespace;701 702    /**703     * Converts an array of reflection objects to JSON.704     * @param array Object array705     * @param [toJSONOptions] JSON conversion options706     * @returns JSON object or `undefined` when array is empty707     */708    public static arrayToJSON(array: ReflectionObject[], toJSONOptions?: IToJSONOptions): ({ [k: string]: any }|undefined);709 710    /**711     * Tests if the specified id is reserved.712     * @param reserved Array of reserved ranges and names713     * @param id Id to test714     * @returns `true` if reserved, otherwise `false`715     */716    public static isReservedId(reserved: ((number[]|string)[]|undefined), id: number): boolean;717 718    /**719     * Tests if the specified name is reserved.720     * @param reserved Array of reserved ranges and names721     * @param name Name to test722     * @returns `true` if reserved, otherwise `false`723     */724    public static isReservedName(reserved: ((number[]|string)[]|undefined), name: string): boolean;725}726 727/** Base class of all reflection objects containing nested objects. This is not an actual class but here for the sake of having consistent type definitions. */728export abstract class NamespaceBase extends ReflectionObject {729 730    /** Nested objects by name. */731    public nested?: { [k: string]: ReflectionObject };732 733    /** Nested objects of this namespace as an array for iteration. */734    public readonly nestedArray: ReflectionObject[];735 736    /**737     * Converts this namespace to a namespace descriptor.738     * @param [toJSONOptions] JSON conversion options739     * @returns Namespace descriptor740     */741    public toJSON(toJSONOptions?: IToJSONOptions): INamespace;742 743    /**744     * Adds nested objects to this namespace from nested object descriptors.745     * @param nestedJson Any nested object descriptors746     * @returns `this`747     */748    public addJSON(nestedJson: { [k: string]: AnyNestedObject }): Namespace;749 750    /**751     * Gets the nested object of the specified name.752     * @param name Nested object name753     * @returns The reflection object or `null` if it doesn't exist754     */755    public get(name: string): (ReflectionObject|null);756 757    /**758     * Gets the values of the nested {@link Enum|enum} of the specified name.759     * This methods differs from {@link Namespace#get|get} in that it returns an enum's values directly and throws instead of returning `null`.760     * @param name Nested enum name761     * @returns Enum values762     * @throws {Error} If there is no such enum763     */764    public getEnum(name: string): { [k: string]: number };765 766    /**767     * Adds a nested object to this namespace.768     * @param object Nested object to add769     * @returns `this`770     * @throws {TypeError} If arguments are invalid771     * @throws {Error} If there is already a nested object with this name772     */773    public add(object: ReflectionObject): Namespace;774 775    /**776     * Removes a nested object from this namespace.777     * @param object Nested object to remove778     * @returns `this`779     * @throws {TypeError} If arguments are invalid780     * @throws {Error} If `object` is not a member of this namespace781     */782    public remove(object: ReflectionObject): Namespace;783 784    /**785     * Defines additial namespaces within this one if not yet existing.786     * @param path Path to create787     * @param [json] Nested types to create from JSON788     * @returns Pointer to the last namespace created or `this` if path is empty789     */790    public define(path: (string|string[]), json?: any): Namespace;791 792    /**793     * Resolves this namespace's and all its nested objects' type references. Useful to validate a reflection tree, but comes at a cost.794     * @returns `this`795     */796    public resolveAll(): Namespace;797 798    /**799     * Recursively looks up the reflection object matching the specified path in the scope of this namespace.800     * @param path Path to look up801     * @param filterTypes Filter types, any combination of the constructors of `protobuf.Type`, `protobuf.Enum`, `protobuf.Service` etc.802     * @param [parentAlreadyChecked=false] If known, whether the parent has already been checked803     * @returns Looked up object or `null` if none could be found804     */805    public lookup(path: (string|string[]), filterTypes: (any|any[]), parentAlreadyChecked?: boolean): (ReflectionObject|null);806 807    /**808     * Looks up the reflection object at the specified path, relative to this namespace.809     * @param path Path to look up810     * @param [parentAlreadyChecked=false] Whether the parent has already been checked811     * @returns Looked up object or `null` if none could be found812     */813    public lookup(path: (string|string[]), parentAlreadyChecked?: boolean): (ReflectionObject|null);814 815    /**816     * Looks up the {@link Type|type} at the specified path, relative to this namespace.817     * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.818     * @param path Path to look up819     * @returns Looked up type820     * @throws {Error} If `path` does not point to a type821     */822    public lookupType(path: (string|string[])): Type;823 824    /**825     * Looks up the values of the {@link Enum|enum} at the specified path, relative to this namespace.826     * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.827     * @param path Path to look up828     * @returns Looked up enum829     * @throws {Error} If `path` does not point to an enum830     */831    public lookupEnum(path: (string|string[])): Enum;832 833    /**834     * Looks up the {@link Type|type} or {@link Enum|enum} at the specified path, relative to this namespace.835     * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.836     * @param path Path to look up837     * @returns Looked up type or enum838     * @throws {Error} If `path` does not point to a type or enum839     */840    public lookupTypeOrEnum(path: (string|string[])): Type;841 842    /**843     * Looks up the {@link Service|service} at the specified path, relative to this namespace.844     * Besides its signature, this methods differs from {@link Namespace#lookup|lookup} in that it throws instead of returning `null`.845     * @param path Path to look up846     * @returns Looked up service847     * @throws {Error} If `path` does not point to a service848     */849    public lookupService(path: (string|string[])): Service;850}851 852/** Namespace descriptor. */853export interface INamespace {854 855    /** Namespace options */856    options?: { [k: string]: any };857 858    /** Nested object descriptors */859    nested?: { [k: string]: AnyNestedObject };860}861 862/** Any extension field descriptor. */863type AnyExtensionField = (IExtensionField|IExtensionMapField);864 865/** Any nested object descriptor. */866type AnyNestedObject = (IEnum|IType|IService|AnyExtensionField|INamespace|IOneOf);867 868/** Base class of all reflection objects. */869export abstract class ReflectionObject {870 871    /** Options. */872    public options?: { [k: string]: any };873 874    /** Parsed Options. */875    public parsedOptions?: { [k: string]: any[] };876 877    /** Unique name within its namespace. */878    public name: string;879 880    /** Parent namespace. */881    public parent: (Namespace|null);882 883    /** Whether already resolved or not. */884    public resolved: boolean;885 886    /** Comment text, if any. */887    public comment: (string|null);888 889    /** Defining file name. */890    public filename: (string|null);891 892    /** Reference to the root namespace. */893    public readonly root: Root;894 895    /** Full name including leading dot. */896    public readonly fullName: string;897 898    /**899     * Converts this reflection object to its descriptor representation.900     * @returns Descriptor901     */902    public toJSON(): { [k: string]: any };903 904    /**905     * Called when this object is added to a parent.906     * @param parent Parent added to907     */908    public onAdd(parent: ReflectionObject): void;909 910    /**911     * Called when this object is removed from a parent.912     * @param parent Parent removed from913     */914    public onRemove(parent: ReflectionObject): void;915 916    /**917     * Resolves this objects type references.918     * @returns `this`919     */920    public resolve(): ReflectionObject;921 922    /**923     * Gets an option value.924     * @param name Option name925     * @returns Option value or `undefined` if not set926     */927    public getOption(name: string): any;928 929    /**930     * Sets an option.931     * @param name Option name932     * @param value Option value933     * @param [ifNotSet] Sets the option only if it isn't currently set934     * @returns `this`935     */936    public setOption(name: string, value: any, ifNotSet?: boolean): ReflectionObject;937 938    /**939     * Sets a parsed option.940     * @param name parsed Option name941     * @param value Option value942     * @param propName dot '.' delimited full path of property within the option to set. if undefined\empty, will add a new option with that value943     * @returns `this`944     */945    public setParsedOption(name: string, value: any, propName: string): ReflectionObject;946 947    /**948     * Sets multiple options.949     * @param options Options to set950     * @param [ifNotSet] Sets an option only if it isn't currently set951     * @returns `this`952     */953    public setOptions(options: { [k: string]: any }, ifNotSet?: boolean): ReflectionObject;954 955    /**956     * Converts this instance to its string representation.957     * @returns Class name[, space, full name]958     */959    public toString(): string;960}961 962/** Reflected oneof. */963export class OneOf extends ReflectionObject {964 965    /**966     * Constructs a new oneof instance.967     * @param name Oneof name968     * @param [fieldNames] Field names969     * @param [options] Declared options970     * @param [comment] Comment associated with this field971     */972    constructor(name: string, fieldNames?: (string[]|{ [k: string]: any }), options?: { [k: string]: any }, comment?: string);973 974    /** Field names that belong to this oneof. */975    public oneof: string[];976 977    /** Fields that belong to this oneof as an array for iteration. */978    public readonly fieldsArray: Field[];979 980    /** Comment for this field. */981    public comment: (string|null);982 983    /**984     * Constructs a oneof from a oneof descriptor.985     * @param name Oneof name986     * @param json Oneof descriptor987     * @returns Created oneof988     * @throws {TypeError} If arguments are invalid989     */990    public static fromJSON(name: string, json: IOneOf): OneOf;991 992    /**993     * Converts this oneof to a oneof descriptor.994     * @param [toJSONOptions] JSON conversion options995     * @returns Oneof descriptor996     */997    public toJSON(toJSONOptions?: IToJSONOptions): IOneOf;998 999    /**1000     * Adds a field to this oneof and removes it from its current parent, if any.1001     * @param field Field to add1002     * @returns `this`1003     */1004    public add(field: Field): OneOf;1005 1006    /**1007     * Removes a field from this oneof and puts it back to the oneof's parent.1008     * @param field Field to remove1009     * @returns `this`1010     */1011    public remove(field: Field): OneOf;1012 1013    /**1014     * OneOf decorator (TypeScript).1015     * @param fieldNames Field names1016     * @returns Decorator function1017     */1018    public static d<T extends string>(...fieldNames: string[]): OneOfDecorator;1019}1020 1021/** Oneof descriptor. */1022export interface IOneOf {1023 1024    /** Oneof field names */1025    oneof: string[];1026 1027    /** Oneof options */1028    options?: { [k: string]: any };1029}1030 1031/**1032 * Decorator function as returned by {@link OneOf.d} (TypeScript).1033 * @param prototype Target prototype1034 * @param oneofName OneOf name1035 */1036type OneOfDecorator = (prototype: object, oneofName: string) => void;1037 1038/**1039 * Parses the given .proto source and returns an object with the parsed contents.1040 * @param source Source contents1041 * @param [options] Parse options. Defaults to {@link parse.defaults} when omitted.1042 * @returns Parser result1043 */1044export function parse(source: string, options?: IParseOptions): IParserResult;1045 1046/** Result object returned from {@link parse}. */1047export interface IParserResult {1048 1049    /** Package name, if declared */1050    package: (string|undefined);1051 1052    /** Imports, if any */1053    imports: (string[]|undefined);1054 1055    /** Weak imports, if any */1056    weakImports: (string[]|undefined);1057 1058    /** Syntax, if specified (either `"proto2"` or `"proto3"`) */1059    syntax: (string|undefined);1060 1061    /** Populated root instance */1062    root: Root;1063}1064 1065/** Options modifying the behavior of {@link parse}. */1066export interface IParseOptions {1067 1068    /** Keeps field casing instead of converting to camel case */1069    keepCase?: boolean;1070 1071    /** Recognize double-slash comments in addition to doc-block comments. */1072    alternateCommentMode?: boolean;1073 1074    /** Use trailing comment when both leading comment and trailing comment exist. */1075    preferTrailingComment?: boolean;1076}1077 1078/** Options modifying the behavior of JSON serialization. */1079export interface IToJSONOptions {1080 1081    /** Serializes comments. */1082    keepComments?: boolean;1083}1084 1085/**1086 * Parses the given .proto source and returns an object with the parsed contents.1087 * @param source Source contents1088 * @param root Root to populate1089 * @param [options] Parse options. Defaults to {@link parse.defaults} when omitted.1090 * @returns Parser result1091 */1092export function parse(source: string, root: Root, options?: IParseOptions): IParserResult;1093 1094/** Wire format reader using `Uint8Array` if available, otherwise `Array`. */1095export class Reader {1096 1097    /**1098     * Constructs a new reader instance using the specified buffer.1099     * @param buffer Buffer to read from1100     */1101    constructor(buffer: Uint8Array);1102 1103    /** Read buffer. */1104    public buf: Uint8Array;1105 1106    /** Read buffer position. */1107    public pos: number;1108 1109    /** Read buffer length. */1110    public len: number;1111 1112    /**1113     * Creates a new reader using the specified buffer.1114     * @param buffer Buffer to read from1115     * @returns A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader}1116     * @throws {Error} If `buffer` is not a valid buffer1117     */1118    public static create(buffer: (Uint8Array|Buffer)): (Reader|BufferReader);1119 1120    /**1121     * Reads a varint as an unsigned 32 bit value.1122     * @returns Value read1123     */1124    public uint32(): number;1125 1126    /**1127     * Reads a varint as a signed 32 bit value.1128     * @returns Value read1129     */1130    public int32(): number;1131 1132    /**1133     * Reads a zig-zag encoded varint as a signed 32 bit value.1134     * @returns Value read1135     */1136    public sint32(): number;1137 1138    /**1139     * Reads a varint as a signed 64 bit value.1140     * @returns Value read1141     */1142    public int64(): Long;1143 1144    /**1145     * Reads a varint as an unsigned 64 bit value.1146     * @returns Value read1147     */1148    public uint64(): Long;1149 1150    /**1151     * Reads a zig-zag encoded varint as a signed 64 bit value.1152     * @returns Value read1153     */1154    public sint64(): Long;1155 1156    /**1157     * Reads a varint as a boolean.1158     * @returns Value read1159     */1160    public bool(): boolean;1161 1162    /**1163     * Reads fixed 32 bits as an unsigned 32 bit integer.1164     * @returns Value read1165     */1166    public fixed32(): number;1167 1168    /**1169     * Reads fixed 32 bits as a signed 32 bit integer.1170     * @returns Value read1171     */1172    public sfixed32(): number;1173 1174    /**1175     * Reads fixed 64 bits.1176     * @returns Value read1177     */1178    public fixed64(): Long;1179 1180    /**1181     * Reads zig-zag encoded fixed 64 bits.1182     * @returns Value read1183     */1184    public sfixed64(): Long;1185 1186    /**1187     * Reads a float (32 bit) as a number.1188     * @returns Value read1189     */1190    public float(): number;1191 1192    /**1193     * Reads a double (64 bit float) as a number.1194     * @returns Value read1195     */1196    public double(): number;1197 1198    /**1199     * Reads a sequence of bytes preceeded by its length as a varint.1200     * @returns Value read

Showing the first 1,200 of 2742 lines. Download the file for the rest.