{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.test/filelovenote/document.schema.json",
  "title": "Rebuild normalized document boundary",
  "description": "Required rebuild boundary, not a claim that the current source validates JSON Schema. Node-specific attrs/defaults are defined by chapter 13. Extensions require explicit schemas; no automatic arbitrary-node acceptance.",
  "type": "object",
  "required": [
    "id",
    "title",
    "folderId",
    "content",
    "createdAt",
    "updatedAt",
    "trashedAt"
  ],
  "properties": {
    "id": {
      "$ref": "#/$defs/appId"
    },
    "title": {
      "type": "string"
    },
    "folderId": {
      "$ref": "#/$defs/appId"
    },
    "content": {
      "allOf": [
        {
          "$ref": "#/$defs/node"
        },
        {
          "properties": {
            "type": {
              "const": "doc"
            }
          }
        }
      ]
    },
    "createdAt": {
      "type": "integer",
      "minimum": 0
    },
    "updatedAt": {
      "type": "integer",
      "minimum": 0
    },
    "trashedAt": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0
    },
    "trashedVia": {
      "type": "string"
    },
    "questions": {
      "type": "array"
    },
    "goalReferences": {
      "type": "array"
    },
    "goalStatus": {
      "enum": [
        "uncompleted",
        "in_progress",
        "completed",
        "cancelled"
      ]
    },
    "goalUrgency": {
      "enum": [
        "high",
        "low"
      ]
    },
    "goalImportance": {
      "enum": [
        "high",
        "low"
      ]
    },
    "forcedLanguage": {
      "type": [
        "string",
        "null"
      ]
    },
    "driveFileId": {
      "type": "string"
    },
    "driveRevision": {
      "type": "string"
    },
    "driveReadError": {
      "type": "string"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "node": {
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "attrs": {
          "type": "object"
        },
        "text": {
          "type": "string"
        },
        "content": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/node"
          }
        },
        "marks": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "type": "string"
              },
              "attrs": {
                "type": "object"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "serverDriveMetadata": {
      "type": "object",
      "properties": {
        "fileId": {
          "type": "string"
        },
        "revision": {
          "type": "string"
        },
        "etag": {
          "type": "string"
        },
        "hash": {
          "type": "string"
        },
        "deleted": {
          "type": "boolean"
        },
        "updatedAt": {
          "type": "number"
        },
        "source": {
          "type": "string"
        },
        "lastToken": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "appId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "pattern": "^[A-Za-z0-9_-]+$",
      "not": {
        "enum": [
          "__proto__",
          "constructor",
          "prototype"
        ]
      }
    }
  }
}
