// package: nanoapp.std.shell
// file: shell.proto

import * as shell_pb from "./shell_pb";
import {grpc} from "@improbable-eng/grpc-web";

type CommandExec = {
  readonly methodName: string;
  readonly service: typeof Command;
  readonly requestStream: false;
  readonly responseStream: true;
  readonly requestType: typeof shell_pb.CommandReq;
  readonly responseType: typeof shell_pb.CommandRes;
};

export class Command {
  static readonly serviceName: string;
  static readonly Exec: CommandExec;
}

export type ServiceError = { message: string, code: number; metadata: grpc.Metadata }
export type Status = { details: string, code: number; metadata: grpc.Metadata }

interface UnaryResponse {
  cancel(): void;
}
interface ResponseStream<T> {
  cancel(): void;
  on(type: 'data', handler: (message: T) => void): ResponseStream<T>;
  on(type: 'end', handler: (status?: Status) => void): ResponseStream<T>;
  on(type: 'status', handler: (status: Status) => void): ResponseStream<T>;
}
interface RequestStream<T> {
  write(message: T): RequestStream<T>;
  end(): void;
  cancel(): void;
  on(type: 'end', handler: (status?: Status) => void): RequestStream<T>;
  on(type: 'status', handler: (status: Status) => void): RequestStream<T>;
}
interface BidirectionalStream<ReqT, ResT> {
  write(message: ReqT): BidirectionalStream<ReqT, ResT>;
  end(): void;
  cancel(): void;
  on(type: 'data', handler: (message: ResT) => void): BidirectionalStream<ReqT, ResT>;
  on(type: 'end', handler: (status?: Status) => void): BidirectionalStream<ReqT, ResT>;
  on(type: 'status', handler: (status: Status) => void): BidirectionalStream<ReqT, ResT>;
}

export class CommandClient {
  readonly serviceHost: string;

  constructor(serviceHost: string, options?: grpc.RpcOptions);
  exec(requestMessage: shell_pb.CommandReq, metadata?: grpc.Metadata): ResponseStream<shell_pb.CommandRes>;
}

