/**
* @license
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
///
import * as Protobuf from 'protobufjs';
import * as descriptor from 'protobufjs/ext/descriptor';
import { Options } from './util';
import Long = require('long');
export { Options, Long };
/**
* 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:
*
* ```ts
* if (isAnyExtension(message)) {
* switch (message['@type']) {
* case TYPE1_URL:
* handleType1(message as AnyExtension & Type1);
* break;
* case TYPE2_URL:
* handleType2(message as AnyExtension & Type2);
* break;
* // ...
* }
* }
* ```
*/
export interface AnyExtension {
/**
* The fully qualified name of the message type that this object represents,
* possibly including a URL prefix.
*/
'@type': string;
}
export declare function isAnyExtension(obj: object): obj is AnyExtension;
declare module 'protobufjs' {
interface Type {
toDescriptor(protoVersion: string): Protobuf.Message & descriptor.IDescriptorProto;
}
interface RootConstructor {
new (options?: Options): Root;
fromDescriptor(descriptorSet: descriptor.IFileDescriptorSet | Protobuf.Reader | Uint8Array): Root;
fromJSON(json: Protobuf.INamespace, root?: Root): Root;
}
interface Root {
toDescriptor(protoVersion: string): Protobuf.Message & descriptor.IFileDescriptorSet;
}
interface Enum {
toDescriptor(protoVersion: string): Protobuf.Message & descriptor.IEnumDescriptorProto;
}
}
export interface Serialize {
(value: T): Buffer;
}
export interface Deserialize {
(bytes: Buffer): T;
}
export interface ProtobufTypeDefinition {
format: string;
type: object;
fileDescriptorProtos: Buffer[];
}
export interface MessageTypeDefinition extends ProtobufTypeDefinition {
format: 'Protocol Buffer 3 DescriptorProto';
}
export interface EnumTypeDefinition extends ProtobufTypeDefinition {
format: 'Protocol Buffer 3 EnumDescriptorProto';
}
export declare enum IdempotencyLevel {
IDEMPOTENCY_UNKNOWN = "IDEMPOTENCY_UNKNOWN",
NO_SIDE_EFFECTS = "NO_SIDE_EFFECTS",
IDEMPOTENT = "IDEMPOTENT"
}
export interface NamePart {
name_part: string;
is_extension: boolean;
}
export interface UninterpretedOption {
name?: NamePart[];
identifier_value?: string;
positive_int_value?: number;
negative_int_value?: number;
double_value?: number;
string_value?: string;
aggregate_value?: string;
}
export interface MethodOptions {
deprecated: boolean;
idempotency_level: IdempotencyLevel;
uninterpreted_option: UninterpretedOption[];
[k: string]: unknown;
}
export interface MethodDefinition {
path: string;
requestStream: boolean;
responseStream: boolean;
requestSerialize: Serialize;
responseSerialize: Serialize;
requestDeserialize: Deserialize;
responseDeserialize: Deserialize;
originalName?: string;
requestType: MessageTypeDefinition;
responseType: MessageTypeDefinition;
options: MethodOptions;
}
export interface ServiceDefinition {
[index: string]: MethodDefinition