UNPKG

@pqstudio/protobuf_ts_plugin

Version:

The protocol buffer compiler plugin "protobuf-ts" generates TypeScript, gRPC-web, Twirp, and more.

133 lines (132 loc) 4.5 kB
/** * Custom file options interpreted by @protobuf-ts/plugin */ import * as rt from "@protobuf-ts/runtime"; import { FileDescriptorProto, FileOptions_OptimizeMode as OptimizeMode, IStringFormat, ServiceDescriptorProto } from "@pqstudio/protobuf_ts_framework"; import { Interpreter } from "./interpreter"; /** * Custom file options interpreted by @protobuf-ts/plugin * The extensions are declared in protobuf-ts.proto */ export interface OurFileOptions { /** * Exclude field or method options from being emitted in reflection data. * * For example, to stop the data of the "google.api.http" method option * from being exported in the reflection information, set the following * file option: * * ```proto * option (ts.exclude_options) = "google.api.http"; * ``` * * The option can be set multiple times. * `*` serves as a wildcard and will greedily match anything. */ readonly ["ts.exclude_options"]: readonly string[]; } /** * Custom service options interpreted by @protobuf-ts/plugin */ export interface OurServiceOptions { /** * Generate a client for this service with this style. * Can be set multiple times to generate several styles. */ readonly ["ts.client"]: ClientStyle[]; /** * Generate a server for this service with this style. * Can be set multiple times to generate several styles. */ readonly ["ts.server"]: ServerStyle[]; } /** * Read the custom file options declared in protobuf-ts.proto */ export declare function readOurFileOptions(file: FileDescriptorProto): OurFileOptions; /** * Read the custom service options declared in protobuf-ts.proto */ export declare function readOurServiceOptions(service: ServiceDescriptorProto): OurServiceOptions; /** * The available client styles from @protobuf-ts/plugin * The extensions are declared in protobuf-ts.proto */ export declare enum ClientStyle { /** * Do not emit a client for this service. */ NO_CLIENT = 0, /** * Use the call implementations of @protobuf-ts/runtime-rpc. * This is the default behaviour. */ CALL_CLIENT = 1, /** * Use promises as return type. * This style can only be used for unary methods (no server or client * streaming). */ PROMISE_CLIENT = 2, /** * Use Observables from the "rxjs" package for requests and responses. */ RX_CLIENT = 3 } /** * The available server styles from @protobuf-ts/plugin * The extensions are declared in protobuf-ts.proto */ export declare enum ServerStyle { /** * Do not emit a server for this service. * This is the default behaviour. */ NO_SERVER = 0, /** * Generate a generic server interface. * Adapters be used to serve the service, for example @protobuf-ts/grpc-backend * for gRPC. */ GENERIC_SERVER = 1, /** * Generate a server for @grpc/grpc-js. */ GRPC_SERVER = 2 } /** * Internal settings for the file generation. */ export interface InternalOptions { readonly pluginCredit?: string; readonly normalLongType: rt.LongType; readonly emitAngularAnnotations: boolean; readonly synthesizeEnumZeroValue: string | false; readonly oneofKindDiscriminator: string; readonly angularCoreImportPath: string; readonly runtimeAngularImportPath: string; readonly runtimeRpcImportPath: string; runtimeImportPath: string; } export declare function makeInternalOptions(options?: Partial<InternalOptions>): InternalOptions; export declare class OptionResolver { private readonly interpreter; private readonly stringFormat; private readonly params; constructor(interpreter: Interpreter, stringFormat: IStringFormat, params: { force_optimize_code_size: boolean; force_optimize_speed: boolean; optimize_code_size: boolean; force_server_none: boolean; server_none: boolean; server_generic: boolean; server_grpc: boolean; force_client_none: boolean; client_none: boolean; client_rx: boolean; client_promise: boolean; }); getOptimizeMode(file: FileDescriptorProto): OptimizeMode; getClientStyles(descriptor: ServiceDescriptorProto): ClientStyle[]; getServerStyles(descriptor: ServiceDescriptorProto): ServerStyle[]; }