import { CallOptions, Client, ClientReadableStream, ClientUnaryCall, ClientWritableStream, Metadata, ServiceError } from "@grpc/grpc-js"; /** * Picks all function properties of a type that except for those with a specific return type */ export type ExcludeReturnType = Pick U ? never : K; }[keyof T]>; /** * Picks all function properties of a type that have the specific return type */ export type PickReturnType = Pick U ? K : never; }[keyof T]>; /** * Returns all properties of a type without those of the base type B */ export type OmitBaseMethods = { [prop in Exclude]: C[prop]; }; /** * Matches a gRPC method that returns a ClientReadableStream */ export type StreamCall = (request: T, metadata?: Metadata | CallOptions, options?: CallOptions) => ClientReadableStream; /** * Matches a gRPC method that returns a ClientWritableStream */ export type WritableStreamCall = (metadata: Metadata | CallOptions | ((err: ServiceError | null, value?: U | undefined) => void), options?: CallOptions | ((err: ServiceError | null, value?: U | undefined) => void) | undefined, callback?: (err: ServiceError | null, value?: U | undefined) => void | undefined) => ClientWritableStream; /** * Matches a gRPC method that returns a ClientUnaryCall */ export type UnaryCall = (request: T, metadata: Metadata | CallOptions, options: Partial, callback: (err: ServiceError | null, res?: U) => void) => ClientUnaryCall; /** * A promise-wrapped gRPC call shape. */ export type PromisifiedCall = (request: T, metadata?: Metadata, options?: Partial) => Promise; /** * Wraps all unary calls with a promisified signature. */ export type PromisifiedCallbackClient = { [prop in Exclude>, keyof Client>, keyof PickReturnType>>]: C[prop] extends UnaryCall ? PromisifiedCall : never; }; /** * Wraps all stream calls with a promisified signature. */ export type PromisifiedStreamClient = { [prop in Exclude>, keyof Client>]: C[prop] extends StreamCall ? PromisifiedCall : never; }; export type WritableStreamClient = { [prop in Exclude>, keyof Client>]: C[prop] extends WritableStreamCall ? WritableStreamCall : never; }; /** * Merges unary/stream promisified signatures into a single client. */ export type PromisifiedClient = PromisifiedCallbackClient & PromisifiedStreamClient & WritableStreamClient;