{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "chapter": {
      "properties": {
        "estMin": {
          "minimum": 0,
          "type": "integer"
        },
        "id": {
          "maxLength": 100,
          "type": "string"
        },
        "pageCount": {
          "minimum": 0,
          "type": "integer"
        },
        "prefix": {
          "maxLength": 150,
          "type": "string"
        },
        "rangeFrom": {
          "minimum": 0,
          "type": "integer"
        },
        "rangeTo": {
          "minimum": 0,
          "type": "integer"
        },
        "title": {
          "maxLength": 600,
          "type": "string"
        },
        "unit": {
          "maxLength": 60,
          "type": "string"
        }
      },
      "required": [
        "id",
        "title"
      ],
      "type": "object"
    },
    "main": {
      "description": "A learning material (textbook, course, etc.) with chapter divisions. rkey is the client's localId (see the `localId` property below), written via putRecord — this makes a retried push idempotent (a network-timeout retry overwrites the same rkey instead of creating a duplicate) rather than requiring the client to track which pushes already succeeded.",
      "key": "any",
      "record": {
        "properties": {
          "accent": {
            "description": "Accent color (hex code)",
            "maxLength": 7,
            "type": "string"
          },
          "backgroundImage": {
            "accept": [
              "image/*"
            ],
            "description": "User-selected image blob. ISBN-derived cover bytes are never uploaded.",
            "maxSize": 5000000,
            "type": "blob"
          },
          "backgroundImageRemoved": {
            "type": "boolean"
          },
          "backgroundImageUri": {
            "description": "Legacy remote image URL only. New selected images use a blob; local URIs are never written.",
            "type": "string"
          },
          "chapters": {
            "description": "List of chapters in this material",
            "items": {
              "ref": "#chapter",
              "type": "ref"
            },
            "maxLength": 500,
            "type": "array"
          },
          "createdAt": {
            "description": "Material creation date (YYYY-MM-DD)",
            "type": "string"
          },
          "description": {
            "maxLength": 1500,
            "type": "string"
          },
          "isbn": {
            "description": "ISBN of the tracked book. The cover image itself is never stored here; it is resolved on-device from this ISBN.",
            "maxLength": 20,
            "type": "string"
          },
          "isbnRemoved": {
            "type": "boolean"
          },
          "localId": {
            "description": "Matches local Material.id and equals this record's own rkey (see the record-level description above).",
            "maxLength": 100,
            "type": "string"
          },
          "pdsRkey": {
            "description": "Canonical migrated TID rkey. It points to a create-only copy while the legacy source record remains readable.",
            "format": "tid",
            "type": "string"
          },
          "subjectId": {
            "description": "Associated subject ID if any",
            "maxLength": 100,
            "type": "string"
          },
          "subjectName": {
            "description": "Subject name snapshot",
            "maxLength": 300,
            "type": "string"
          },
          "syncedAt": {
            "format": "datetime",
            "type": "string"
          },
          "title": {
            "description": "Material title",
            "maxLength": 600,
            "type": "string"
          }
        },
        "required": [
          "localId",
          "title",
          "accent",
          "createdAt"
        ],
        "type": "object"
      },
      "type": "record"
    }
  },
  "id": "app.studynext.material",
  "lexicon": 1
}
