{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.wrimo.co/schemas/project-v1.schema.json",
  "title": "WriMo project, schema version 1",
  "description": "A WriMo project file (project.json): the project, its chapters and their rich text. IDs are stable UUIDs; revision increases with every save. extensions maps hold namespaced data (for example org.wrimo.demo); WriMo does not yet promise to keep extension data it does not recognize. WriMo also requires IDs to be unique across the project, chapters and headings, heading levels 1 to 3 with an ID on every heading, and content its editor can open; JSON Schema cannot express those rules.",
  "type": "object",
  "properties": {
    "format": {
      "type": "string",
      "enum": [
        "wrimo",
        "writemo"
      ]
    },
    "schemaVersion": {
      "type": "number",
      "const": 1
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "title": {
      "type": "string",
      "maxLength": 300
    },
    "revision": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
    },
    "chapters": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "title": {
            "type": "string",
            "maxLength": 300
          },
          "content": {
            "$ref": "#/$defs/RichNode"
          },
          "origin": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "documentId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "revision": {
                    "type": "string"
                  }
                },
                "required": [
                  "documentId",
                  "revision"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "extensions": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        },
        "required": [
          "id",
          "title",
          "content",
          "origin",
          "extensions"
        ],
        "additionalProperties": false
      }
    },
    "extensions": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    }
  },
  "required": [
    "format",
    "schemaVersion",
    "id",
    "title",
    "revision",
    "updatedAt",
    "chapters",
    "extensions"
  ],
  "additionalProperties": false,
  "$defs": {
    "RichNode": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "doc",
            "paragraph",
            "text",
            "heading",
            "bulletList",
            "orderedList",
            "listItem",
            "blockquote",
            "codeBlock",
            "hardBreak",
            "horizontalRule"
          ]
        },
        "attrs": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        },
        "text": {
          "type": "string"
        },
        "marks": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "bold",
                  "italic",
                  "strike",
                  "code",
                  "underline",
                  "link"
                ]
              },
              "attrs": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              }
            },
            "required": [
              "type"
            ]
          }
        },
        "content": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/RichNode"
          }
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": false
    }
  }
}
