{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "StoryLocator": {
      "description": "Story scope. Defaults to document body when omitted. Use {kind:'story', storyType:'body'} for body, or other storyType values for headers, footers, footnotes, endnotes.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "body"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "headerFooterSlot"
            },
            "section": {
              "$ref": "#/$defs/SectionAddress"
            },
            "headerFooterKind": {
              "enum": [
                "header",
                "footer"
              ]
            },
            "variant": {
              "enum": [
                "default",
                "first",
                "even"
              ]
            },
            "resolution": {
              "enum": [
                "effective",
                "explicit"
              ]
            },
            "onWrite": {
              "enum": [
                "materializeIfInherited",
                "editResolvedPart",
                "error"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "section",
            "headerFooterKind",
            "variant"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "headerFooterPart"
            },
            "refId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "refId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "footnote"
            },
            "noteId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "noteId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "endnote"
            },
            "noteId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "noteId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "textbox"
            },
            "textboxId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "textboxId"
          ]
        }
      ]
    },
    "SectionAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "section"
        },
        "sectionId": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "sectionId"
      ]
    }
  },
  "operationId": "changes.get",
  "schemas": {
    "input": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "required": [
        "id"
      ]
    },
    "output": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "Deterministic id: identical transactions yield identical ids in every session."
            },
            "seq": {
              "type": "integer",
              "minimum": 1
            },
            "revision": {
              "type": "string"
            },
            "origin": {
              "enum": [
                "local",
                "remote"
              ]
            },
            "actor": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "claim": {
                      "type": "string",
                      "description": "Application-supplied identity claim. SuperDoc does not verify it."
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "id"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "contributors": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "claim": {
                    "type": "string",
                    "description": "Application-supplied identity claim. SuperDoc does not verify it."
                  }
                },
                "additionalProperties": false,
                "required": [
                  "id"
                ]
              }
            },
            "actorType": {
              "oneOf": [
                {
                  "enum": [
                    "human",
                    "code"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "cause": {
              "oneOf": [
                {
                  "enum": [
                    "user",
                    "api",
                    "undo",
                    "redo"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "provenance": {
              "enum": [
                "authored",
                "declared",
                "relayed",
                "unknown"
              ]
            },
            "at": {
              "type": "object",
              "properties": {
                "declared": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "observed": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "declared",
                "observed"
              ]
            },
            "session": {
              "type": "object",
              "properties": {
                "id": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "clientId": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "additionalProperties": false,
              "required": [
                "id",
                "clientId"
              ]
            },
            "changeTag": {
              "type": "string"
            },
            "changes": {
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "text"
                      },
                      "story": {
                        "$ref": "#/$defs/StoryLocator"
                      },
                      "blockId": {
                        "type": "string"
                      },
                      "range": {
                        "type": "object",
                        "properties": {
                          "start": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "end": {
                            "type": "integer",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "start",
                          "end"
                        ]
                      },
                      "inserted": {
                        "type": "string"
                      },
                      "deleted": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "story",
                      "blockId",
                      "range",
                      "inserted",
                      "deleted"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "format"
                      },
                      "story": {
                        "$ref": "#/$defs/StoryLocator"
                      },
                      "blockId": {
                        "type": "string"
                      },
                      "range": {
                        "type": "object",
                        "properties": {
                          "start": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "end": {
                            "type": "integer",
                            "minimum": 0
                          }
                        },
                        "additionalProperties": false,
                        "required": [
                          "start",
                          "end"
                        ]
                      },
                      "attributes": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "story",
                      "blockId",
                      "range",
                      "attributes"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "paragraph"
                      },
                      "story": {
                        "$ref": "#/$defs/StoryLocator"
                      },
                      "blockId": {
                        "type": "string"
                      },
                      "properties": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "story",
                      "blockId",
                      "properties"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "split"
                      },
                      "story": {
                        "$ref": "#/$defs/StoryLocator"
                      },
                      "blockId": {
                        "type": "string"
                      },
                      "tailBlockId": {
                        "type": "string"
                      },
                      "offset": {
                        "type": "integer",
                        "minimum": 0
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "story",
                      "blockId",
                      "tailBlockId",
                      "offset"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "merge"
                      },
                      "story": {
                        "$ref": "#/$defs/StoryLocator"
                      },
                      "blockId": {
                        "type": "string"
                      },
                      "mergedBlockId": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "story",
                      "blockId",
                      "mergedBlockId"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "move"
                      },
                      "story": {
                        "$ref": "#/$defs/StoryLocator"
                      },
                      "blockId": {
                        "type": "string"
                      },
                      "afterBlockId": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "story",
                      "blockId",
                      "afterBlockId"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "create"
                      },
                      "story": {
                        "$ref": "#/$defs/StoryLocator"
                      },
                      "blockId": {
                        "type": "string"
                      },
                      "text": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "story",
                      "blockId",
                      "text"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "remove"
                      },
                      "story": {
                        "$ref": "#/$defs/StoryLocator"
                      },
                      "blockId": {
                        "type": "string"
                      },
                      "text": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "story",
                      "blockId",
                      "text"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "table"
                      },
                      "story": {
                        "$ref": "#/$defs/StoryLocator"
                      },
                      "tableId": {
                        "type": "string"
                      },
                      "detail": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "story",
                      "tableId",
                      "detail"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "const": "sidecar"
                      },
                      "affects": {
                        "enum": [
                          "comment",
                          "trackedChange",
                          "bookmark"
                        ]
                      },
                      "ids": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "affects",
                      "ids"
                    ]
                  }
                ]
              }
            },
            "update": {
              "type": "string",
              "description": "Base64 Yjs v1 update for exactly this transaction."
            }
          },
          "additionalProperties": false,
          "required": [
            "id",
            "seq",
            "revision",
            "origin",
            "actor",
            "actorType",
            "cause",
            "provenance",
            "at",
            "session",
            "changes"
          ]
        },
        {
          "type": "null"
        }
      ]
    }
  }
}
