type Mutation {
  appendCellOutput(input: AppendCellOutputInput!): Boolean
  changeCellType(input: ChangeCellTypeInput!): Cell!
  clearCellOutputs(id: ID): Boolean
  deleteCell(id: ID!): Boolean
  insertCell(input: InsertCellInput!): Cell!
  moveCell(input: MoveCellInput!): Boolean
  patchCellSource(input: PatchCellSourceInput!): Boolean
  replaceCell(input: ReplaceCellInput!): Cell!
  updateCellMetadata(input: UpdateCellMetadataInput!): Boolean
  updateNotebookMetadata(input: UpdateNotebookMetadataInput!): Boolean
  updatePresence(input: UpdatePresenceInput!): Boolean
  upsertNotebook(input: UpsertNotebookInput!): UpsertNotebookPayload!
}

input UpsertNotebookInput {
  id: ID!
  content: NotebookContentInput!
  createNew: Boolean
}

input NotebookContentInput {
  cells: [CellInput!]
  metadata: [MetadataInput!]
}

input CellInput {
  code: CodeCellInput
  markdown: TextCellInput
  raw: TextCellInput
}

input CodeCellInput {
  source: String!
  metadata: [MetadataInput!]
  executionCount: Int
  outputs: [OutputInput!]
}

input TextCellInput {
  source: String!
  metadata: [MetadataInput!]
}

input MetadataInput {
  key: String!
  value: String!
}

input MediaBundleInput {
  key: String!
  value: String!
}

input OutputInput {
  displayData: DisplayDataInput
  error: ErrorOutputInput
  executeResult: ExecuteResultInput
  stream: StreamOutputInput
}

input ExecuteResultInput {
  executionCount: Int
  data: [MediaBundleInput!]
  metadata: [MetadataInput!]
}

input DisplayDataInput {
  data: [MediaBundleInput!]
  metadata: [MetadataInput!]
}

input StreamOutputInput {
  name: OutputStreamType
  text: String
}

input ErrorOutputInput {
  ename: String
  evalue: String
  traceback: [String!]
}

type UpsertNotebookPayload {
  notebook: Notebook
}

input InsertCellInput {
  insertAt: Int
  cell: CellInput!
}

input MoveCellInput {
  id: ID!
  insertAt: Int!
}

input ChangeCellTypeInput {
  id: ID!
  cellType: String!
}

enum CellType {
  code
  markdown
  raw
}

enum DiffType {
  insert
  delete
  replace
}

input PatchCellSourceInput {
  id: ID!
  type: DiffType!
  diff: String
  start: Int!
  len: Int
}

input UpdatePresenceInput {
  focusedCellId: ID!
  cursorPosition: PositionInput
  textSelection: SelectionRangeInput
}

input PositionInput {
  line: Int!
  column: Int!
}

input SelectionRangeInput {
  lineStart: Int!
  columnStart: Int!
  lineEnd: Int!
  columnEnd: Int!
}

input ReplaceCellInput {
  id: ID!
  cell: CellInput!
}

input UpdateNotebookMetadataInput {
  metadata: MetadataInput!
}

input UpdateCellMetadataInput {
  id: ID!
  metadata: MetadataInput!
}

input AppendCellOutputInput {
  id: ID!
  output: OutputInput!
}
