package sbt.protocol
@target(Scala)
@codecPackage("sbt.protocol.codec")
@fullCodec("JsonProtocol")

## Message to invoke command.
interface CommandMessage {
}

type InitCommand implements CommandMessage {
  token: String
  execId: String
  skipAnalysis: Boolean @since("1.4.0")
}

## Command to execute sbt command.
type ExecCommand implements CommandMessage {
  commandLine: String!
  execId: String @since("0.0.1")
}

type SettingQuery implements CommandMessage {
  setting: String!
}

type Attach implements CommandMessage {
  interactive: Boolean!
}

type CompletionParams {
  query: String!
  level: Int @since("1.4.0")
}

## Message for events.
interface EventMessage {
}

type ChannelAcceptedEvent implements EventMessage {
  channelName: String!
}

## Log event.
type LogEvent implements EventMessage {
  level: String!
  message: String!
}

## Status event.
type ExecStatusEvent implements EventMessage {
  status: String!
  channelName: String
  execId: String
  commandQueue: [String]
  exitCode: Long @since("1.1.2")
  message: String @since("1.4.0")
}

interface SettingQueryResponse implements EventMessage {}

type SettingQuerySuccess implements SettingQueryResponse {
  value: sjsonnew.shaded.scalajson.ast.unsafe.JValue!
  contentType: String!
}

type SettingQueryFailure implements SettingQueryResponse {
  message: String!
}

type CompletionResponse {
  items: [String]
  cachedMainClassNames: Boolean @since("1.4.0")
  cachedTestNames: Boolean @since("1.4.0")
}

# enum Status {
#  Ready
#  Processing
# }

## Execution event.
type ExecutionEvent {
  success: String!
  commandLine: String!
}

type TerminalPropertiesResponse implements EventMessage {
  width: Int!
  height: Int!
  isAnsiSupported: Boolean!
  isColorEnabled: Boolean!
  isSupershellEnabled: Boolean!
  isEchoEnabled: Boolean!
}

type TerminalCapabilitiesQuery implements CommandMessage {
  boolean: String
  numeric: String
  string: String
}

type TerminalCapabilitiesResponse implements EventMessage {
  boolean: Boolean
  numeric: Int
  string: String
}

type TerminalSetAttributesCommand implements CommandMessage {
  iflag: String!,
  oflag: String!,
  cflag: String!,
  lflag: String!,
  cchars: String!,
}

type TerminalSetAttributesResponse implements EventMessage {}

type TerminalAttributesQuery implements CommandMessage {}

type TerminalAttributesResponse implements EventMessage {
  iflag: String!,
  oflag: String!,
  cflag: String!,
  lflag: String!,
  cchars: String!,
}

type TerminalGetSizeQuery implements CommandMessage {}
type TerminalGetSizeResponse implements EventMessage {
  width: Int!
  height: Int!
}

type TerminalSetSizeCommand implements CommandMessage {
  width: Int!
  height: Int!
}

type TerminalSetSizeResponse implements EventMessage {}

type TerminalSetEchoCommand implements CommandMessage {
  toggle: Boolean!
}

type TerminalSetEchoResponse implements EventMessage {}

type TerminalSetRawModeCommand implements CommandMessage {
  toggle: Boolean!
}

type TerminalSetRawModeResponse implements EventMessage {}
