{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "BlockNodeAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "block"
        },
        "nodeType": {
          "enum": [
            "paragraph",
            "heading",
            "listItem",
            "table",
            "tableRow",
            "tableCell",
            "tableOfContents",
            "image",
            "sdt"
          ]
        },
        "nodeId": {
          "type": "string"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "nodeType",
        "nodeId"
      ]
    },
    "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": "index.insert",
  "schemas": {
    "input": {
      "type": "object",
      "properties": {
        "at": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "documentStart"
                }
              },
              "additionalProperties": false,
              "required": [
                "kind"
              ]
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "documentEnd"
                }
              },
              "additionalProperties": false,
              "required": [
                "kind"
              ]
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "before"
                },
                "target": {
                  "$ref": "#/$defs/BlockNodeAddress"
                }
              },
              "additionalProperties": false,
              "required": [
                "kind",
                "target"
              ]
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "after"
                },
                "target": {
                  "$ref": "#/$defs/BlockNodeAddress"
                }
              },
              "additionalProperties": false,
              "required": [
                "kind",
                "target"
              ]
            }
          ]
        },
        "config": {
          "type": "object",
          "properties": {
            "headingSeparator": {
              "type": "string"
            },
            "entryPageSeparator": {
              "type": "string"
            },
            "pageRangeSeparator": {
              "type": "string"
            },
            "sequenceId": {
              "type": "string"
            },
            "columns": {
              "type": "integer"
            },
            "entryTypeFilter": {
              "type": "string"
            },
            "pageRangeBookmark": {
              "type": "string"
            },
            "letterRange": {
              "type": "object",
              "properties": {
                "from": {
                  "type": "string"
                },
                "to": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "from",
                "to"
              ]
            },
            "runIn": {
              "type": "boolean"
            },
            "accentedSorting": {
              "type": "boolean"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false,
      "required": [
        "at"
      ]
    },
    "output": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "success": {
              "const": true
            },
            "index": {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "block"
                },
                "nodeType": {
                  "const": "index"
                },
                "nodeId": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "kind",
                "nodeType",
                "nodeId"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "success",
            "index"
          ]
        },
        {
          "type": "object",
          "properties": {
            "success": {
              "const": false
            },
            "failure": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                },
                "details": {}
              },
              "additionalProperties": false,
              "required": [
                "code",
                "message"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "success",
            "failure"
          ]
        }
      ]
    },
    "success": {
      "type": "object",
      "properties": {
        "success": {
          "const": true
        },
        "index": {
          "type": "object",
          "properties": {
            "kind": {
              "const": "block"
            },
            "nodeType": {
              "const": "index"
            },
            "nodeId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "nodeType",
            "nodeId"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "success",
        "index"
      ]
    },
    "failure": {
      "type": "object",
      "properties": {
        "success": {
          "const": false
        },
        "failure": {
          "type": "object",
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "details": {}
          },
          "additionalProperties": false,
          "required": [
            "code",
            "message"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "success",
        "failure"
      ]
    }
  }
}
